Is it possible to change the XML that ASP.NET sends when querying a web service?

I’m trying to integrate my web application into a web service provided by a 3rd party.

I added the web service by simply adding a Service Reference with the provided WSDL. My app queries the web service as below:

using (var client = new ServiceReference.WebServiceClient()) { // client.fetchOperation("TEST9876", "test4139", "SWITCHON", "509", "", "0") response = await client.fetchOperationAsync(USER, PASS, PACKAGE, "509", "", "0"); } 

It isn’t really important to know what information this call returns right now since it isn’t working anyway.

This generates the following HTTP request (as taken from Fiddler)

POST https://myservice.gateway.thing HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: "" Host: myservice.gateway.thing Content-Length: 816 Expect: 100-continue Accept-Encoding: gzip, deflate Connection: Keep-Alive <s:Envelope xmlns:s=""> <s:Header> <ActivityId CorrelationId="04a608d9-fbfd-4a4d-b26b-e57098352dff" xmlns=""> 80000162-0005-fb00-b63f-84710c7967bb</ActivityId> <VsDebuggerCausalityData xmlns="">uIDPo6GoRTTueVZOiE2QS303TwoAAAAA6GBrNOg50ESdf6d7KUk2nMLdj/sn/wxCqk4Df+zV1yQACQAA</VsDebuggerCausalityData> </s:Header> <s:Body xmlns:xsi="" xmlns:xsd=""> <fetchOperation xmlns="http://myservice.gateway.thing/v1"> <user>TEST9876</user> <passwd>test4139</passwd><!-- plain text password ftw! --> <package>SWITCHON</package> <txType>509</txType> <swref/> <force>0</force> </fetchOperation> </s:Body> </s:Envelope> 

I keep getting back an error saying Cannot find child element: user. I’ve queried this with the web service admin and he told me that I need to change fetchOperation from the above to the following:

 <v1:fetchOperation xmlns:v1="http://myservice.gateway.thing/v1"> <user>TEST9876</user> <passwd>test4139</passwd><!-- plain text password ftw! --> <package>SWITCHON</package> <txType>509</txType> <swref/> <force>0</force> </v1:fetchOperation> 

Semantically I don’t see any difference between what I’m already sending and what he’s suggesting I send instead as both should be functionally identical but whatever the case, I have no idea how to make this change since it means editing the XML that ASP.NET is outputting via the configs and definitions provided by the WSDL.

Any ideas how I can do this? Any ideas for a possible workaround?

submitted by /u/lcyduh
[link] [comments]

Leave a Reply