WCF / ASMX :: Xml Processing Instructions In XmlDocument Returned By Web Service
Jan 20, 2010
I'm having a confusing issue concerning web services, XmlDocument return type and XmlProcessingInstruction. I've basically got a web service that returns an XmlDocument containing a list of search results. In order to make it a little more user-friendly, I'd like the XmlDocument to include a Processing Instruction (<?xml-stylesheet type='text/xsl' href='book.xsl'?>) for the inclusion of an XSL stylesheet. Is there something in the ASP.NET pipeline that would prevent this? I'm using the following code (lifted from the MSDN documentation of the CreateProcessingInstruction() method) in a test WebMethod and it doesn't seem to include the processing instruction.
I have a web service that returns an object that I attach to a gridview's datasource. is there a way to sort the data from the web service before attaching it to the datasource?
A sample web service app I have been practicing with has two web methods: 1) HelloWorld -- which I can read the data from no problem - just a string 2) ClientData[] -- which returns an array of struct objects -- this is where I have the question.
Here is my instantiation of the webservice in my winform app for reading from HelloWorld
myWebSvc1.WebService1 s1 = new myWebSvc1.WebService1(); string y = s1.HelloWorld(); //--no problems so far here Console.WriteLine(y); //--but when I add the call to GetClientData() I have a problem List<ClientData> ls = new List<ClientData>(s1.GetClientData(3)); //--problem here
public struct ClientData { public String Name; public int ID; } [WebMethod(CacheDuration = 30, Description="Returns an array of Clients.")] public ClientData[] GetClientData(int Number) { ClientData [] Clients = null; if (Number > 0 && Number <= 10) { Clients = new ClientData[Number]; for (int i = 0; i < Number; i++) { Clients[i].Name = "Client " + i.ToString(); Clients[i].ID = i; } } return Clients; }
If I browse the .asmx file -- the sample xml returns the following if I enter 3 for GetClientData function param
From my winform app I get the following error messages when trying to add the GetClientData function call above --
Error 1 The best overloaded method match for 'System.Collections.Generic.List<DSS_2008.Form7.ClientData[]>.List(System.Collections.Generic.IEnumerable<DSS_2008.Form7.ClientData[]>)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'DSS_2008.myWebSvc1.ClientData[]' to 'System.Collections.Generic.IEnumerable<DSS_2008.Form7.ClientData[]>'
Error1 The best overloaded method match for 'System.Collections.Generic.List<DSS_2008.Form7.ClientData[]>.List(int)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'DSS_2008.myWebSvc1.ClientData[]' to 'int'
How can I fix this so that I can read the result into my winform app? //--sample web service
namespace MyService { using System; using System.Collections; using System.Data; using System.Web; using System.Web.Services; public struct ClientData { public String Name; public int ID; } /// <summary> /// Summary description for WebService1. /// </summary> [WebService(Namespace="http://codeproject.com/webservices/", Description="This is a demonstration WebService.")] public class WebService1 : System.Web.Services.WebService { //--source of sample: http://www.codeproject.com/KB/webservices/myservice.aspx private const int CacheHelloWorldTime = 10; // seconds public WebService1() { //CODEGEN: This call is required by the ASP+ Web Services Designer InitializeComponent(); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { } //WEB SERVICE EXAMPLE //The HelloWorld() example service returns the string Hello World //To build, uncomment the following lines then save and build the project //To test, right-click the Web Service's .asmx file and select View in Browser // [WebMethod(CacheDuration = CacheHelloWorldTime, Description="As simple as it gets - the ubiquitous Hello World.")] public string HelloWorld() { return "Hello World bbb"; } [WebMethod(CacheDuration = 30, Description="Returns an array of Clients.")] public ClientData[] GetClientData(int Number) { ClientData [] Clients = null; if (Number > 0 && Number <= 10) { Clients = new ClientData[Number]; for (int i = 0; i < Number; i++) { Clients[i].Name = "Client " + i.ToString(); Clients[i].ID = i; } } return Clients; } } }
I have recently converted all my applications to framework 4.0 and am very happy as a whole.
I have, however, run into a bit of a bind: i have exposed quite a few web services that have methods returning datasets.
Clients immediately started complaining that the order of the tables within the returned datasets were different. I investigated and can confirm that the webmethods are indeed shuffling the tables within the datasets. The order of tables in the method result are markedly different from the table order in the code before being returned.
My question is: is it possible to hard code the order of tables within the dataset being returned by a webmethod? I know that clients should, ideally, be referencing the tables via the table names, but that is - unfortunately - not the case in the really real world.
I'm maintaining a legacy XML web service system (Framework 2.0), and is trying to return an XML fragment as part of a SOAP response. Problem is: SOAP will auto-enclose the XML fragment in <[CData[]]> tag, and I want to avoid this.
I wrote a webmethod (Called SearchData()) in which the method makes a httpwebrequest to another url and gets the data in xmldocument. After getting the xmlDocument ,it is returned to SearchData method invoker. When i invoke the from browser it works fine. But When another application in java tries to consume this webmethod SearchData(), it is getting the error
<wsdl:part name="Body"/>
and each part should be type defined. The WSDL file is not well formatted. it doesn't have Type defined at each element. How to fix this.or Is there any other Better way to provide the end user the xml(ie from httpwebrequest result in webmethod ) with a soap wrapper ie with a well defined wsdl. My code :
I am using a third party service for location time(zonal).If I pass latitude and longitude of the location with service URL it returns the time of that location in XML format.But the problem is some of the time this service gets too much slow so because of that my home page gets stuck because its a synchronous call of that service.here my code-
At the other end I am returning the following XML response:
[Code]....
I'm seeing my response.writes of A and B, so I know my data is making it to the other end and I'm getting a response back, but I can't seem to figure out how to read the response and redirect to the URL referenced in <URL>
I have an web application which needs some calculations and processing on data. This job is a long running job(few hours). Job is initiated by user.
Requirement.
User Clicks on Process Data. Some functions are called to start data processing. Data Processing runs for hours. User is given feedback of percentage completed etc. Even if user logs off and then again log on he should get this feedback.
The requirement is somewhat similar to Spiceworks. Where it runs in background to detect the devices/computers in network and the user is notified in his page about the progress. But spicework uses windows service. We don't want to us windows service.
Now the question is.
What if user closes the page, will the task still run in background. This task has to be completed fully.If terminated in between output will not have any meaning. How to actually to design this long running process. In ASP.Net environment. Also is there a way to show all/same user who logs in the status of processing.
I have to call a function to run a report through a web service, then call another function to get the data but only after the 1st function has finished processing. How do I make c# wait till the first function has finished processing to run the second function?
my code looks something like:
NetworkCredential Cred = new NetworkCredential("uid", "pw"); ReportWebService reportService = new ReportWebService(); reportService.Credentials = Cred; string s = reportService.runReportAsync("0ede9884e6394daf73fa418e9bffd4fc"); string report = reportService.getReportData(s);
This code will break because s is not set since the function (runreportasynch) has not finished running to produce s.
just wanna ask you something. My requirement is that I need to download a large file.So,at the web server, there are a lot of zip files are packeted and when user request a link to download the file, those packeted zipped files will be combined into one large file and download it. So, I have done all the others steps. what I want to know is when user clicked that download link, I pop up another web form and wanna show processing progress or loading icon while zipped files are unzipping. Because unzipping time may take around 3 to 5 minutes depends on file sizes. Now I called the unzip function at the page load event, but it does not appear anything until unzip function has finished. guide me in which event or what kind of mechanism or technology should I use to show icon at the UI while processing at back end code.
I've been given merely a wsdl above from client, without any further information given, to make a call using c# code but i added as web reference, used the codes below and the client side detected my request and they've returned us proper format xml too, but i cant retrieve it in the string array from the method returned. the "stringset" has became null instead of array[10]. Can anyone give a hint what kind of web service call is it, since it is not using the simple and classic way to invoke?
static void Main(string[] args) { //added web reference for wsdl as poccrm string[] stringset = new string[10]; poccrm.poclib caller = new ConsoleApplication1.poccrm.poclib(); poccrm.SE1I2001 callerItem = new poccrm.SE1I2001(); callerItem.AcctNo = "0010241000007914"; callerItem.TransNo = "12345678901234567890"; callerItem.StartDate = "20-01-2010"; stringset = caller.SE1I2001(callerItem); //here i get null for stringset, but client received the request and returned us value //same result even I use wsdl.exe converted it to a class file /* string[] stringset = new string[10]; poclib caller = new poclib(); SU1I1001 callerItem = new SU1I1001(); callerItem.AcctNo = "0010029004000370"; callerItem.transno = "12345678901234567890"; caller.end stringset = caller.SU1I1001(callerItem); */ }
I have a .net app consuming a java web service. I added the web reference in visual studio to the proper wsdl, it created the proper proxy class and I can call the web service without any problems but looking at the result that is returned, it is always nothing. I can see, by using Fiddler, that the response is returning what it should. If there is a response, why is the return object never being populated and no errors are thrown?
if i have the web application with many pages like add order page, edit order page, and delete order page actually they also interact with the Sql Server 2008 and i also create web service page call Sales_Service.asmx. i know just i need to put something like query into Web Method in Sales_Service.asmx but i have a lot of queries, i don't know which query i should put into it and how the web page call the Sales_Services.asmx
A customer reported that our asmx web service is continually increasing in memory (mem usage as well as private bytes). We are able to reproduce the problem in our lab with Windows 2003 Server SP2 (fully patched) on some of the machines. The customer is using Windows 2008.
We created a Hello World web service targeting the 2.0 framework built under VS2005 SP1 and a test client that continues to call it. The memory increases steadily - approximately 40K per client request. If the test app is paused, the memory remains the same. When it is closed, the memory drops. Explicit calling of GC.Collect does not drop the memory.
We have run the memory profiler on the service and the leak is all native memory. We have uninstalled/re-installed the Framework on one of the machines but no difference. To our knowledge all of the security and IIS settings are not modified. We have compared app pool, default web site and virtual directory properties to machines that have no problem and they are identical.
I would like to makea windows service. whenever the user of my ASP.NET application has to do a time-consuming task, the IIS would give the task to the service which will return a token(a temporary name for the task) and in the background the service would do the task. At anytime, the user would see the status of his/her task which would be either pending in queue, processing, or completed. The service would do a fixed number of jobs in parallel, and would keep a queue for the next-incoming tasks. In addition there would be a WinForms application for system administrator that would allow adding special ADMIn tasks such as "Clean orphaned files" or "archive data of inactive users".
Can you point me to something that can jump start me on this as a whole concept - I know I can google for windows services and I am able to do it myself from scratch but time is of the Essence so maybe you know of something that is already there and i can use block to build out of.
I have a .net app developed in .net 4.0 version. And I implemented an asmx web service in this. Now I want to call one of the webservice method in another classis ASP application java script function.
Is it possible to run a web service as a particular user/service account in the same way a Windows service can?I have a service account used for connecting to the DB and want to run the webservice under this account as the users using the webservice won't have DB access.The way I see to do it is to include the Impersonate option in the Web.config file, but is there any better way to do this?
How to create an instance of web service without adding web service reference? How to identify the server address/name where the web service is hosted from C# code?