title: Working with Cisco WSMA from .NET (part two)
body: <p>First, take a quick look at my other question (<a href="https://stackoverflow.com/questions/3658385/working-with-cisco-wsma-from-net">part 1</a>). 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.</p>
  
  <p>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.</p>
  
  <p>In the Cisco <a href="http://www.ciscosysteme.com/en/US/docs/ios/netmgmt/configuration/guide/nm_cfg_wsma.html#wp1106394" rel="nofollow noreferrer">documentation</a>, there are several examples of valid SOAP requests, such as this one:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
    &lt;SOAP:Body&gt;
      &lt;request xmlns="urn:cisco:wsma-config" correlator="4.1"&gt;
        &lt;configApply details="all"&gt;
          &lt;config-data&gt;
            &lt;cli-config-data&gt;
              &lt;cmd&gt;no cns config partial mixy&lt;/cmd&gt;
              &lt;cmd&gt;no stupid&lt;/cmd&gt;
              &lt;cmd&gt;no cns exec 80 &lt;/cmd&gt;
            &lt;/cli-config-data&gt;
          &lt;/config-data&gt;
        &lt;/configApply&gt;
      &lt;/request&gt;
    &lt;/SOAP:Body&gt;
  &lt;/SOAP:Envelope&gt;]]&gt;]]&gt;
  </code></pre>
  
  <p>Using WCF trace, I verify that the request I'm sending looks like this:</p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;request correlator="1" xmlns="urn:cisco:wsma-config"&gt;
        &lt;configApply action-on-fail="rollback" details="all"&gt;
          &lt;config-data&gt;
            &lt;cli-config-data&gt;
              &lt;cmd xsi:type="xsd:string"&gt;hostname Gunnar&lt;/cmd&gt;
            &lt;/cli-config-data&gt;
          &lt;/config-data&gt;
        &lt;/configApply&gt;
      &lt;/request&gt;
    &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>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?</p>
  
  <p>Still, the response I invariably get is:</p>
  
  <pre><code>&lt;SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xml="http://www.w3.org/XML/1998/namespace"&gt;
    &lt;s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;/s:Header&gt;
    &lt;SOAP:Body&gt;
      &lt;SOAP:Fault&gt;
        &lt;faultcode xmlns=""&gt;SOAP:Client&lt;/faultcode&gt;
        &lt;faultstring xmlns=""&gt;An expected XML tag or sequence is missing&lt;/faultstring&gt;
        &lt;detail xmlns=""&gt;
          &lt;WSMA-ERR:error xmlns:WSMA-ERR="urn:cisco:wsma-errors"&gt;
            &lt;WSMA-ERR:tag&gt;xml&lt;/WSMA-ERR:tag&gt;
            &lt;WSMA-ERR:details&gt;XML_ERROR_MISSING_ELEMENT&lt;/WSMA-ERR:details&gt;
          &lt;/WSMA-ERR:error&gt;
        &lt;/detail&gt;
      &lt;/SOAP:Fault&gt;
    &lt;/SOAP:Body&gt;
  &lt;/SOAP:Envelope&gt;
  </code></pre>
  
  <p>I can't see that any element is missing.</p>
  
  <p>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?</p>