Problem when switching from SoapClient to WebServicesClientProtocol
From: Wil Rodriguez (loopback_at_wilrod.com)
Date: 08/31/04
- Next message: SP: "HOLDEVL34 Trying to use MyUsernameTokenmanager"
- Next in thread: SA: "Re: Problem when switching from SoapClient to WebServicesClientProtocol"
- Reply: SA: "Re: Problem when switching from SoapClient to WebServicesClientProtocol"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 30 Aug 2004 17:46:17 -0700
I have a working C# class library that acts as a soap client. It was
implemented by extending the SoapClient object which gave me full control
over the formatting of the soap body:
public class InventoryProxy : SoapClient
{ ...working code goes here...}
The vendor providing the web service will be requiring that all soap
messages (requests) be digitally signed, and later on also encrypted. So,
I've switched the base class for my library from SoapClient to
Microsoft.Web.Services2.WebServicesClientProtocol. The only problem that
I've run into so far is trying to get the message body formatted properly.
It all boils down to the "this.invoke()" method requiring an object array
and me not being able to figure out how to populate this array such that the
resulting soap body looks like this:
<soap:Body>
<InventoryRequest xmlns="Vendor.WebServices/Inventory>
<Widgets>
<Widget DeptId="2">Hammer</Widget>
<Widget DeptId="2">Nail</Widget>
</Widgets>
</InventoryRequest>
</soap:Body>
The closest I've gotten so far has been passing in a string array that gets
cast as an object array when calling the this.invoke() method:
//populate the test widgets array
string[] widgets = new string[] {"<Widget DeptId=\"2\">Hammer</Widget>",
"<Widget DeptId=\"2\">Nail</Widget>"};
//pass the array into the invoking function
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://my.vendor
.com/Inventory.asmx", RequestNamespace="Vendor.WebServices/Inventory",
ResponseElementName="InventoryResponse",
ResponseNamespace="Vendor.WebServices/Inventory",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public object[]
InventoryRequest([System.Xml.Serialization.XmlArrayAttribute(IsNullable=true
)] [System.Xml.Serialization.XmlArrayItemAttribute("Widget",
IsNullable=false)] string[] widgets) {
return this.Invoke("InventoryRequest", new object[] {widgets});
}
But, when I trace the client input the soap body looks like this (and is
rejected by the web service):
<soap:Body>
<InventoryRequest xmlns="Vendor.WebServices/Inventory">
<Widgets>
<Widget><Widget DeptId="2" >Hammer</Widget></Widget>
<Widget><Widget DeptId="2">Nail</Widget></Widget>
</Widgets>
</InventoryRequest>
</soap:Body>
It looks like the parameters in the Widgets[] array are treated as Inner
Text. If I just put the product name in the string array (i.e. string[]
widgets = new string[] {"Hammer", "Nail"};) then I get XML elements that
look normal, but then I'm missing the required DeptId attributes for each
Widget element:
<soap:Body>
<InventoryRequest xmlns="Vendor.WebServices/Inventory">
<Widgets>
<Widget>Hammer</Widget>
<Widget>Nail</Widget>
</Widgets>
</InventoryRequest>
</soap:Body>
Yes, I am a still a newbie, so any help/pointers on what I'm doing wrong or
how I can better control the formatting of the message body would be highly
appreciated.
Thanks,
Wil
- Next message: SP: "HOLDEVL34 Trying to use MyUsernameTokenmanager"
- Next in thread: SA: "Re: Problem when switching from SoapClient to WebServicesClientProtocol"
- Reply: SA: "Re: Problem when switching from SoapClient to WebServicesClientProtocol"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|