Hi
First, take a quick look at my other question (part 1). It tells of how I want to call web services on a Cisco router (The Web Services Management Agent - WSMA) from .NET 4 using WCF.
I have applied Ladislav's technique, and gotten very far. However, I'm now at a stage where I'm pretty confident that I'm sending well-formed SOAP requests, yet the router does not accept it.
In the Cisco documentation, there are several examples of valid SOAP requests, such as this one:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP:Body>
<request xmlns="urn:cisco:wsma-config" correlator="4.1">
<configApply details="all">
<config-data>
<cli-config-data>
<cmd>no cns config partial mixy</cmd>
<cmd>no stupid</cmd>
<cmd>no cns exec 80 </cmd>
</cli-config-data>
</config-data>
</configApply>
</request>
</SOAP:Body>
</SOAP:Envelope>]]>]]>
Using WCF trace, I verify that the request I'm sending looks like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<request correlator="1" xmlns="urn:cisco:wsma-config">
<configApply action-on-fail="rollback" details="all">
<config-data>
<cli-config-data>
<cmd xsi:type="xsd:string">hostname Gunnar</cmd>
</cli-config-data>
</config-data>
</configApply>
</request>
</s:Body>
</s:Envelope>
To me, that looks pretty damn right. Yes, the xsd and xsi namespaces are declared on the soap body rather than the envelope, but that should make no difference. The action-on-fail attribute is optional, and present in other examples. The xs:type should be OK too. Otherwise, it's completely equivalent. Or?
Still, the response I invariably get is:
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xml="http://www.w3.org/XML/1998/namespace">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"></s:Header>
<SOAP:Body>
<SOAP:Fault>
<faultcode xmlns="">SOAP:Client</faultcode>
<faultstring xmlns="">An expected XML tag or sequence is missing</faultstring>
<detail xmlns="">
<WSMA-ERR:error xmlns:WSMA-ERR="urn:cisco:wsma-errors">
<WSMA-ERR:tag>xml</WSMA-ERR:tag>
<WSMA-ERR:details>XML_ERROR_MISSING_ELEMENT</WSMA-ERR:details>
</WSMA-ERR:error>
</detail>
</SOAP:Fault>
</SOAP:Body>
</SOAP:Envelope>
I can't see that any element is missing.
You don't suppose IOS requires the namespace prefix to be SOAP (rather than s)? That would be utterly stupid, but I'm running out of options (who knows, maybe they don't deserialize the XML, but rather parses it textually). Does anyone know how I can specify the namespace prefix that WCF will use for the SOAP envelope?