The methods xx and yy use the same SOAPAction - c#

We are trying to create a mock service for a web service for testing purposes.
To do this we run wsdl.exe to create an interface and then create an asmx web service based on that interface. We have done this several times over the last years without any problems.
This time we get an error:
The methods xx and yy use the same SOAPAction
When we call the web service. Have done some searching on google, it says that this is a bug with wsdl.exe. But says nothing about what to do about it.
Is there a way to fix this? Should I just delete parts of references.cs?
Thanks
Shiraz

Found the solution. Added the following line as an attribute to the web service class:
[SoapDocumentService(RoutingStyle=SoapServiceRoutingStyle.RequestElement)]
After a clean solution and a rebuild, everything worked.

Related

Methods Missing When Consuming a Web Service

My task includes consuming the Web Service Function which I got from WSDL.
After adding reference to WSDL in C# I am unable to find a service request method by simply calling the class.
Instead it has few other methods to use per service which I am unable to understand how to use them: ServiceNameRequest,
ServiceNameResponse, ServiceNameCompletedEventArgs...
Any idea how to utilize the WSDL in c# with this approach?
Assuming this is a service reference:
Look for ServiceNameClient class. The operations you are looking for will be off of that.
so say its the User service. There should be a UserClient. Off of UserClient you should have things like UserClient.Getuser or UserClient.Adduser etc.

Web API to insert records

I am working on Taleo web API. I have an XML file with several records that I will have to insert into the Taleo system using its web API.
I have got the Taleo API guide from http://tbe.taleo.net/products/TBE_API_Guide.pdf.
For the first time, I am working on web API so I don't know where to start. Although the guide shows some examples using SOAP, I don't know how to make this request and retrieve the response using C# or VB.NET. I googled it but didn't get much information about it. If you share your ideas, I would really appreciate it.
From the PDF, it appears the WSDL for the service is at: http://tbe.taleo.net/wsdl/WebAPI.wsdl. In your C#/VB project, use the "Add Service Reference" option on the context menu and supply that URI to the WSDL. That will generate a proxy and many ancillary classes on which you can call whatever methods you need - the SOAP details are under the covers. You'll instantiate an instance of WebAPIClient and should see all the relevant methods there.
For example, in C# after creating a new Service Reference with (uninspired) namespace name of ServiceReference2, I can code the following (though I have no idea what it does!):
var x = new ServiceReference2.WebAPIClient(); // I suspect there's an overload expecting credentials
ServiceReference2.AccountBean y = x.getAccountById("bar", 0);
Exception handling is left to the reader :)

Calling a web service: what am I doing wrong here?

I have the following code for consuming a service that is not working for me. Can anyone suggest what I can do to narrow down whats going wrong? I know this is vague so please tell me what you require to provide any suggestions.
The address is: http://localhost:57667/ExampleService.svc/
When visiting directly I get the 'You have created a service... message'
The code that goes wrong is here. It causes the following error:
_url = "http://localhost:57667/ExampleService.svc";
TextReader textReader = new StringReader(HttpPostClient.Post(new Uri(_url), bodyData.ToString(), _exampleServiceRequestEncoding, Properties.Settings.Default.HttpPostClientExampleAvailabilityTimeout));
ERROR MESSAGE:
When visiting this URL directly: http://localhost:57667/ExampleService.svc/ProcessRequest
The exception message is 'No component for key example.ExternalWebServiceStubs.Example.ExampleService was found'.
Castle.MicroKernel.DefaultKernel.get_Item(String key) at Castle.Facilities.WcfIntegration.WindsorInstanceProvider.GetInstance
many thanks,
The normal practice would be to create a proxy class via svcutil.exe (visual studio command prompt) or "add service reference" to consume the service, and then for you to use the methods of your proxy class to call your service's methods.
This tutorial should help (it's based on Visual Studio 2005, you didn't say what version you were using, but you should get a good grounding)
http://msdn.microsoft.com/en-us/library/bb332338.aspx#msdnwcfhc_topic6
Since troubleshooting wcf services will be lot more easier when you provide web.config element also at service side.
My general guess here is, all the wcf services by default uses wsHttpBinding which will not allow direct calling of service like an asmx service we do.
You can replace wsHttpBinding with basicHttpBinding and disable the security to your service in order to get the service work like you are expecting.
Please add some more details about ExampleService.svc binding and it will help you get this resolved fast
Hope this will help

WCF 3.5 - Remove SVC Extension - Special Case

I have several RESTful endpoints like such:
System.Security.Role.svc
System.Security.User.svc
etc.
This is meant to be a namespace so our RESTful URL's would look like:
/rest/{class namespace}/{actions}
I have tried a few examples to get the SVC extension removed when my endpoint has multiple periods in it, however, nothing seems to work.
I have tested with the WCF REST Contrib package (http://wcfrestcontrib.codeplex.com/), this example (http://www.west-wind.com/weblog/posts/570695.aspx), and another StackOverflow post (How to remove the ".svc" extension in RESTful WCF service?).
This works great when my endpoint is something like this:
Echo.svc
It will properly remove the SVC extension.
Any ideas on how to handle endpoints with multiple periods in the endpoint name?
EDIT:
After some further testing, I found out that it is failing because whenever you do:
string path = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
If the endpoint contains multiple periods, it strips off everything after the endpoint causing all of the standard IHttpModule's to fail.
Example:
If I call http://localhost/services/Echo/test, my relative app file path has a returned value of:
~/echo/test
However, if I make a call as http://localhost/services/System.Security.User/test, then my relative app file path has a returned value of:
~/system.security.user
I am missing the '/test' on the end in that situation.
Have you tried this solution - How to remove the ".svc" extension in RESTful WCF service?

C# SOAP with a custom URL

Okay, simple situation: I'm writing a simple console application which connects to a SOAP web service. I've imported a SOAP Service reference and as a result, my application has a default endpoint build into it's app.config file.
The web service, however, can run on multiple servers and the URL to the proper web service is passed through the commandline parameters of my application. I can read the URL, but how do I connect the web service to this custom URL?
(It should be very simple, in my opinion. It's something I'm overlooking.)
Is this using an auto-generated class deriving from SoapHttpClientProtocol? If so, just set the Url property when you create an instance of the class.
Well, .NET can provide some very useless error messages sometimes. In IIS, the service was configured to AutoDetect cookieless mode. As a result, I had to append "?AspxAutoDetectCookieSupport=1" to the URL. Although that would fix the problem, it was just easier to go to the IIS console, open the properties of the service, go to the ASP.NET tab page, click the "Edit configuration" button, to to "State Management" in the newly popped up screen and change "Cookieless mode" into something other than "AutoDetect"...
Excuse me. Dumb error. Am going to hit myself on the head a few times for this. ;-)
As Jon said, you set the Url, as in:
Namespace.ClassName nwe = new Namespace.ClassName();
nwe.Url = "http://localhost/MyURL/site.asmx";

Categories