views:

624

answers:

2

I am trying to create a WSDL for a pre-existing web service. I have an existing client and and existing server, and I've captured the format both use using Wireshark. I am trying to write a new client that uses the same format. Therefore I am trying to match the format as closely as possible, be it correct or not. I'm cooking up a WSDL file using XmlSPY, which I hope then to take to C# and generate interface code.

Here is my WSDL so far:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.ecerami.com/wsdl/HelloService.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.ecerami.com/wsdl/HelloService.wsdl" name="HelloService">
 <message name="api:create"/>
 <message name="oanda:create">
  <part name="parameter"/>
  <part name="parameter"/>
 </message>
 <portType name="Oanda_PortType">
  <operation name="create">
   <input message="tns:oanda:create"/>
   <output message="tns:api:create"/>
  </operation>
 </portType>
 <binding name="Oanda_binding" type="tns:Oanda_PortType">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
  <operation name="create">
   <soap:operation soapAction="sayHello"/>
   <input>
    <soap:body use="encoded"  namespace="oanda.fxtrade.api"/>
   </input>
   <output>
    <soap:body use="encoded" namespace="oanda.fxtrade.api"/>
   </output>
  </operation>
 </binding>
 <service name="Oanda_service">
  <documentation>WSDL File for Oanda FX Trade API (local SOAP server)</documentation>
  <port name="Oanda_port" binding="tns:Oanda_binding">
   <soap:address location="http://10.0.0.3:18081"/&gt;
  </port>
 </service>
</definitions>

Here is a sample message I'm trying to copy. This is what the original client emits:

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <oanda:create xmlns:oanda="oanda.fxtrade.api">
      <parameter>FXGAME</parameter>
      <parameter></parameter>
    </oanda:create>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Here is what XmlSPY says my WSDL will emit for the same message:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
     <SOAP-ENV:Body>
      <m:create xmlns:m="oanda.fxtrade.api">
       <parameter/>
       <parameter/>
      </m:create>
     </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

My question for now is - how do I match the "oanda:" prefix generated by the original client? Is this what is called a namespace prefix? Where is the "m:" in my generated code coming from? I can find mentions of this in other examples on this site, but none using WSDL, at least as far as I can tell.

Thank you for any help you can give.

+2  A: 

The namespace prefix does not matter. The two examples are identical by the rules of XML.

John Saunders
That may be true, but I'd still like to change the namespace prefix. Surely there is a way to control it, yes?
Stewart Loving-Gibbard
A: 

When I try to run the above WSDL through svcutil.exe, I get two problems.

1) the XML is not well-formed since you can't have more than one parameter with the same name. XMLSpy was also complaining about this, so I punted on it for now by renaming them to Parameter1 and Parameter2.

The specific error is: "More than one message part named 'parameter' was specified. Each message part must have a unique name."

2) Once past this, I get this error:

"Namespace prefix 'tns:oanda' is not defined."

So, again: How do I change/add a namespace definition in a WSDL file?

Stewart Loving-Gibbard