In visual studio 2008 using .net 3.5 i have consumed a WSDL which has automatically generated a Reference.cs.
This was done by right clicking on References in my project and selecting "Add Web Reference"
Using this i can post to the web service and get valid responses through my ref and out objects. postValues() is a void method.
webService.postValues(ref value1, ref value2, out value3);
Using WireShark i can see the the request and full soap response on my network.
What im trying to figure out is how can i capture this raw SOAP response in my code.
I would like to capture this for logging purposes and would rather not individually serialize each of the ref objects.
I cant see anyway to do this without modifying the automatically generated Reference.cs which id rather not do.
Any help would be appreciated.
Edit: There doesnt seem to be a way to do this that i can see. Can anyone else confirm or deny this?
EDIT. Ill bump this just one more time to see if anyone knows.
You have following options:
Enable tracing for your web service in config, and dump all information into file. If you are using WCF instead of legacy web services, see this question on how to enable tracing for WCF.
Implement your own SoapExtension and plug into message processing pipeline to intercept and dump incoming/outgoing soap messages. I think example in linked artice contain TraceExtension, which does exactly that.
Modify generated Reference.cs and dump passed objects, as you specified.
Related
I have access to WSDL file of a specific web service that contains a SendData method - basically I specify the TimeStamp and Value to be send. I uploaded the WSDL file to my project in Visual Studio 2019 as a connected service (Add->Connected Service->Microsoft WCF Web Service Reference Provider->Browse->I added location of the WSDL file and specified the service that included SendData method). After that I created a new client:
ServiceSoapClient client = new ServiceSoapClient(ServiceSoapClient.EndpointConfiguration.ServiceSoap);
added credentials (the web service requires login):
client.ClientCredentials.UserName.UserName = "test"; client.ClientCredentials.UserName.Password = "test";
created a new variable Data that contains TimeStamp and Value (in a specific format required by the method).
After that I invoked the method:
client.SendData(Data);
but it doesn't work. There are no errors or exceptions thrown, but the Data is not visible on the web service (the web service also has a GUI). I started to wonder if it is possible to send data to a web service in such a way or is it maybe necessary to create an xml file with a request and use HttpWebRequest?
Perhaps someone could help me figure out what is wrong, is there a way to check, what is going on during compilation? Unfortunately, I cannot include the URI or WSDL file, but hopefully my description of the issue will be sufficient. Thanks in advance for any guidance!
Okay, with the suggestion from Robert Harvey (thank you once again) and some trial and error I managed to solve my problem. Hopefully my answer will be useful to someone with the similar issue.
I found out that in some cases WCF web service's calls are not visible in Fiddler. In my case it was due to some packages not being up-to-date. These out-of-date packages were added automatically after connecting the web service via Microsoft WCF Web Service Reference Provider.
System.ServiceModel.Duplex/Http/NetTcp/Security all were installed in version 4.4 instead of 4.7. I updated them using Project->Manage NuGet Packages and now my requests are visible in Fiddler and I managed to verify that the way I used my method was correct, but the access to the web service (with the ability to save data) is currently limited, that is why the result was not visible directly on the web service (in the GUI).
This is going to be a bit long so please bear with me.
I have been beating my head against this issue for quite some time. I am not very experienced in web services from a client and am having real issues setting this up. What I have is a web service from a third part hosted on a site. The service is a WSDL service written in JAVA. I am trying to connect to it from y .NET solution and consume the web services provided. One of the requirements from the vendor is to "set the Headers parameter to 'XXXX' and the value to 'YYYY'"
I am having some serious issues doing this. My first attempt was to simply add the web service as a web reference in Visual Studio (2012). There were no methods exposed by the service to set the header so I simply called a function to see what happened. I received an exception "No SOAP Headers specified".
Next I attempted to create a manual proxy using SVCUTIL.exe. I think there may be something wrong with the web services because I receive errors "Cannot import wsdl:binding": "Detail: The required WSDL extension element 'binding' from namespace 'http://schemas.xmlsoap.org/wsdl/http/' was not handled."
However, the class and config files are still created. Anyways, I imported the class into my web app and updated my web.config with the necessary settings from the proxy config. I declare an instance of the needed class and this is where things go south for this attempt. When declaring an instance of the class I receive the error "could not find default end point element that references contract "ContractName" in the ServiceModel client configuration. This might be because no endpoint element matching this contract could be found in the client element". I am wondering if perhaps there is a problem with the services or they simply weren't designed for .NET. The other obvious option is I am doing something wrong. I would be happy to post the config file and such if you would like to see it (I just felt I had loaded this post enough as it is).
What I am really looking for is instructions (a tutorial would be awesome) on how to add a web service as a reference within Visual Studio c# application but being able to set the headers from within the code.
I am sorry for the length of this post.
Thank you for your help.
I am attempting to connect to the Taleo API from my solution in Visual Studio. The Enterprise API (not to be confused with the Taleo Business Edition API) is a SOAP-based Web Service with a number of WSDL endpoints.
I can successfully query the API in SoapUI, however, I am not having luck when attempting to add a Service Reference in Visual Studio.
Here's what I've tried:
Added a reference to the WSDL (Note the Operations that appear). So far so good...
Visual Studio successfully generates the necessary classes, however, the methods circled above are nowhere to be found. I've searched the API for hours and even ran a few searches in Reflector... they are truly MIA.
A few observations:
I can see the methods when viewing the raw WSDL XML in a browser (if you need a sample, I can post it)
I can query the three methods just fine in SoapUI
It's my understanding that the methods only support HTTP POST, so perhaps Visual Studio is performing a GET and the service is rejecting it? (I've FIDDLED this, and all I see is a 200 response)
I am behind a Proxy (although, I was able to connect in SoapUI without having to configure a proxy)
At this point, I'm considering writing my own SOAP client to perform the queries using an HttpWebRequest, but I thought I would try and figure out what's wrong before diving too deep into that.
Any idea what I'm doing wrong here?
I was also having trouble with the API. When I tried adding the service reference as described by the OP, I received a series of errors in the Error List including the following:
Error: Member BusinessGoal.Items of type System.Object[] hides base
class member BaseMultilingualEntity.Items of type
multilingualStringField[]. Use XmlElementAttribute or
XmlAttributeAttribute to specify a new name.
I was able to use the older Web Reference mechanism to generate the proxy classes. You can find this under Add Service Reference → Advanced → Add Web Reference. This will generate a Reference.cs file that contains the proxy class code for the service. You will need to have Show All Files selected in Visual Studio to see this file buried under the generated Web Reference. (You can also use the WSDL.exe command line tool included with Visual Studio to generate the Reference.cs file)
Using this approach, my proxy class included the methods that were missing, but I still needed to manually edit the Reference.cs file to replace all "[][]" with "[]" as many of the generated types were erroneously created as jagged arrays.
I was unable to add a reference to the Taleo API either through the "Add Service Reference" wizard, or though the legacy "Web Reference" method. I ended up writing my own SOAP client using a HttpWebRequest to get and post the XML directly.
I've been passed a WSDL from a third party. Their web service is PHP on Apache.
I can call its methods from within XMLSpy and Validwsdl.com. But cannot get my C#/Visual Studio project to build/validate the WSDL. When I add it to my project - it shows all of the methods and seems fine but won't build.
I've tried add web ref, add service ref, I've tried command line WSDL.exe. Nothing works. Should I be having to hack at their WSDL document? Do I need extra libraries/includes?
I don't understand why it's not working.
The WSDL is :-
http://www.gesundsolutions.com/epp/application/heiq.wsdl
Any Ideas?
Have you used the "Add Web Reference" from the menu in VS?
A simple and quick tutorial that shows you what is needed for communicating with a web service from elsewhere is this post on op0.com. Check it to find out what you're possibly missing.
Yes, just the WSDL is enough if you know the location of the web service. No, you should never change the WSDL, as that is the calling convention.
I am calling a web service (written in Java) in my web app. I use the WSDL to generate proxy classes using the wsdl.exe command line tool.
Everything is working fine.
However, I have found out that the web service is not doing any data validation at all when they receive a request from my app. Hence, if I happen to send one minute piece of data that isn't exactly what they want, I receive a general fault error in return, with no specifics at all of what the incorrect (if any) piece of data is.
So, before I make the request, I'd like to validate my request against the schema they have provided. Is this possible, and if so, how do I go about this?
Thanks in advance
The proxy built from the wsdl already enforces whatever schema was provided unless, of course, the call takes a string parameter where you are supposed to pass xml. That would be bad design but if that's what you have to do, you can. Just use the XmlDocument object or the XmlReader to validate the XML.