In my project, I included Webservice files, when I tried to run, I got this error in Chrome browser.
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0029: Cannot implicitly convert type 'Unified.WebService.GetOrder [c:\Users\Venkatesh\AppData\Local\Temp\Temporary ASP.NET Files\root\417f2571\29df25a\assembly\dl3\1f05470e\0779ccf4_47dfcd01_0\WasteManagement.DLL]' to 'Unified.WebService.GetOrder [c:\Users\Venkatesh\Desktop\Venkateshwar\Company Related\Waste Management - Copy\WasteManagement\WasteManagement\App_Code\GetOrder.cs(8)]'
Source Error:
Line 43: public GetOrder retrieveOrder(string orderNumber)
Line 44: {
//Calling Web service method in my class
Line 45:/*ERROR*/ return connection.getOrder(orderNumber);
Line 46: }
Line 47:
When I clicked Compiler Warning Messages, it is showing error in all the connections which were through Web service.
If necessary, I will share the code too. (As I am new to asp.net, I cant understand which part of code to share. So, please mention which part of code you want, if needed.)
Your Web-service should be independent project in your solution. After that you should add Web Reference for it, and after that you can safely call it.
Web Service is not a basic class you cann add and use - it is a different thing, so you can't simply add it to your App_Code folder to make it work.
From MSDN:
Web service discovery is the process by which a client locates a Web service and obtains its service description. The process of Web service discovery in Visual Studio involves interrogating a Web site following a predetermined algorithm. The goal of the process is to locate the service description, which is an XML document that uses the Web Services Description Language (WSDL).
The service description describes what services are available and how to interact with those services. Without a service description, it is impossible to programmatically interact with a Web service.
Edit:
Yes, you can remove [WebMethod] attributes, etc, from web service declaration, and temporary use it like class, but after that you still have to add a Web reference for it to use it like Web Service.
Related
We are having the following setup:
A custom DLL (VB.Net) has a web reference to a custom web service (ASP.Net, let's call it WebService0).
This custom DLL is instantiated by custom .Net EXE program, which make use of the exposed functions in the DLL, which in turn make calls to said WebService0.
e.g. .Net EXE Program calls DLL function which calls WebService0.
This setup works fine.
Now, take this setup to another computer, but instead of calling the DLL from a custom program like above, it is being called from yet another web service layer (let's call this one WebService1). And to test this WebService1 there is another .Net EXE program (not the same one mentioned above).
e.g. .Net EXE Program calls WebService1, which calls custom DLL function, which in turn calls WebService0.
For some reason, this setup throws the following exception:
System.Web.Services.Protocols.SoapException: WebService0 has not been properly Initialized
What could be happening? The cause does not seem to be evident. We have checked everything to the best of our knowledge.
We have searched the internet and there is barely any information about it that we could find.
Any help is very much appreciated.
I guess that your WebService1 is the source of this exception, when calling the DLL. And you do NOT have configuration embeded into DLL itself.
You've propably forgot to configure your WebService1 web.config system.serviceModel section.
Take a look at your .Net EXE Program (the first one) and it's App.Config (or YourExeName.exe.config) to see what system.serviceModel section looks like. I expect at least section to be filled.
Do the same in your WebService1/web.config/system.serviceModel
In case my guess is wrong and you've done this already, show us your configuration.
I've created an asp.net web service and am trying to test it using my client. The web method I'm currently testing returns a custom object named GetAllTicketsSinceLastPullDateResult, which contains one ArrayList of custom clsTrip objects, and a custom object called FaultResponse. This is how I'm using my client:
ServiceReference1.ServiceSoapClient myClient = new ServiceReference1.ServiceSoapClient();
ServiceReference1.GetAllTicketsSinceLastPullDateResult result = new ServiceReference1.GetAllTicketsSinceLastPullDateResult();
result = myClient.getAllTicketsSinceLastPullDate(myUser);
But I get the following error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type clsTicket was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
I Google the error and most of the answers I find have to do with serializing derived classes. But my clsTicket class is not a derived class. What can be causing this error? How do I use XmlInclude or SoapInclude?
Thanks in advance!
Okay I finally got it to work, I ended up putting the following line:
[XmlInclude(typeof(clsTicket))]
Between [WebMethod] and my method's definition. So far so good.
I don't think you need to 'new' result:
ServiceReference1.GetAllTicketsSinceLastPullDateResult result;
result = myClient.getAllTicketsSinceLastPullDate(myUser);
Also, how do you know the error isn't on the server?
Can you call the function with a web browser?
Have you updated your service since initially adding the reference to your project? If you're using Visual Studio's "Add Web Reference" feature and you update the service, often times there is a configuration or parameter chance, which can generate SOAP errors.
Try right clicking on the Web Service in question through visual studio and select "Update" option. Recompile the app and see if that resolves your issue.
I want to make a "properties style web form" that shows the application version for various .NET applications.
If I know the URL e.g. /someapp/default.aspx is it possible via reflection to execute that page and figure out the assembly version?
It's quite easy to find the executing assembly version, but without modifying the other application, is it possible?
Both the property page and the other application is running on the same server and in the same application pool.
Update: I've had some luck with
var url = "~/SomeApp/default.aspx";
var appType = System.Web.Compilation.BuildManager.GetCompiledType(url);
But navigating appType to find the assembly file version is not the same everytime.
Without modifying the web application to expose the version number through some URL-based retrieval (a simple page GET being the easy, obvious one), you're going to need to find a way to figure out where the DLL for the web application is from the URL.
If you can know the DLL's location, either by some convention (e.g. /appX/ is always at D:\Sites\appX\bin\appX.dll) or some configuration (you manually enter where each URL base's DLL is in a database), then you can retrieve that DLL's assembly version using the following code:
Assembly assembly = Assembly.LoadFrom("MyAssembly.dll");
Version ver = assembly.GetName().Version;
Code taken from this question.
Edit:
I've had a little look around, and there are some APIs to inspect the IIS configuration, so this is certainly a route to explore if you're trying to get from the URL to the assembly location. This question has an example of getting the physical path from the application/site name, for example. Microsoft.Web.Administration is the assembly to explore.
The ASP.NET engine streams nothing but HTML, javascript, etc.. to the client. There is nothing left of the assembly that gets passed in the response that can show what version of .net/asp.net that the application is running unless the developer on the server side adds it.
That said, you can gather some information from a utility at http://uptime.netcraft.com/up/graph that will give you some server information. Not down to the assembly version, but this is as close as I believe you are going to get.
You may implement custom HttpModule, put it to the bin folder of each application that you wish to monitor and append register this module in web.config files. In this module for example you should handle request, retrieve all required information and put it to response cookie.
I've a simple, if not primitive, C++/CLI .NET 2.0 class library. It is used in order to wrap some C++ legacy code for the Web Service. The following facts appear to be true:
Primitive C# test program calls class library and it works.
If class library does not refer to any modules of our code base, it works as well as part of the web service. That is, I load the web service and invoke the methods and receive proper response.
The same moment I replace the copied and pasted code by the calls from our code base libraries, the Web Service stops to load. I get System.IO.FileNotFoundException message.
The problem: I cannot find any place where the file name that couldn't be found is written.
I googled it and gave some permissions to some ASP.NET user on my computer. I copied all the DLLs of our libraries into the same directory where web service is installed. I searched in IIS logs, event logs, etc - no where could I find the name of the module that prevents the web service from coming up.
Any help on the matter would be greatly appreciated.
Boris
Make sure all the dependent DLLs are in the path (Path meaning not the directory where your assembly is, because ASP.net copies your assembly away into a temporary folder, but rather a directory that's included in the System path environment variable).
What calls are you replacing? Could it be the original code gracefully handles missing files (which may not even be important) and yours does not?
Add same rights to the iusr-account that you did to the asp.net-account.
We have consumed a third party web service and are trying to invoke it from an ASP.NET web application.
However when I instantiate the web service the following System.InvalidOperationException exception is thrown:
Method 'ABC.XYZ' can not be reflected.
System.InvalidOperationException:
Method 'ABC.XYZ' can not be reflected.
---> System.InvalidOperationException: The XML element 'MyDoc' from namespace
'http://mysoftware.com/ns' references
a method and a type. Change the
method's message name using
WebMethodAttribute or change the
type's root element using the
XmlRootAttribute.
From what I can gather there appears to be some ambiguity between a method and a type in the web service.
Can anyone clarify the probably cause of this exception and is there anything I can do to rectify this or should I just go to the web service owners to rectify?
Edit: Visual Studio 2008 has created the proxy class. Unfortunately I can't provide a link to the wsdl as it is a web service for a locally installed thrid party app.
I ran into the same problem earlier today.
The reason was - the class generated by Visual Studio and passed as a parameter into one of the methods did not have a default parameterless constructor. Once I have added it, the error had gone.
It seems the problem is down to data type issues between VS and the web service that was written in Java.
Ultimately it was fixed by manually editing the class and schema files that were created by VS.
I have come across the exact same problem when I was consuming a 3rd party web service. The problem in this instance was that the mustUndertand property in the reference file was looking for a Boolean, whereby the namespace property looked for a string.
By looking through the reference i was able to idenitfy the offending property and simply add "overrides" to the method signature.
Not ideal as any time you update the service you have to do this but I couldn't find any other way around this.
To find the reference file select "all files" from the solution explorer
Hope this helps
I'm guessing the wsdl emitted by or supplied with the service is not in a form that wsdl.exe or serviceutil can understand - can you post the wsdl or link to it?
how are you creating the proxy classes?
Also you might like to try and validate the wsdl against the wsdl schema to check its valid
In my case I was getting a "method cannot be reflected" error due to that fact that in the class being returned by method, I had failed to expose a default parameter-less constructor.
I was working in VB.NET. In my return class I had declared a "New(..)" method that took a couple parameters (because that is how I wanted to use it in my code). But by doing so, I had supressed the default (hidden) parameterless New() constructor that VB adds behind the scenes. Apparently the web service handler requires that a parameterless constructor be available. As soon as I added back into my class a parameterless New() constructor, it all worked fine.
I got the same message but mine was caused by a missing System.Runtime.Serialization.dll since I tried to run a 3.5 application on a machine with only .NET 2.0 installed.
I had the same issue but I found that one of the WebMethod parameters has a member that is of type interface that is why VS could not serialise it. here is the exception when trying to download the disco file
System.InvalidOperationException: Cannot serialize member
'Leopard.JobDespatchParameters.SendingUser'
of type 'Leopard.Interfaces.IUser', see inner exception for more
details. ---> System.NotSupportedException: Cannot serialize member
Leopard.JobDespatchParameters.SendingUser
of type Leopard.Interfaces.IUser because it is an interface.
Old thread but I had a different issue, Maybe of help to someone. referenced dlls were mixed up between two versions on data layer and service layer that caused the problem.
Another scenario where this error can happen: I simply had another web method with the same name (but different parameters)in my web service that slipped in during a code merge. After I deleted the old method it worked.