I've got a WCF SOAP client which is generating a request. This is being refused by the server as an invalid request. I've traced it down to namespaces using SOAPUI but cannot figure out how I can get the client to produce the required result.
The client was generated as a web service reference from the wsdl and is producing the following SOAP message;
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header></s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<createShipmentRequest xmlns="http://www.royalmailgroup.com/api/ship/V2">
<integrationHeader>
<dateTime xmlns="http://www.royalmailgroup.com/integration/core/V1">2015-07-23</dateTime>
<version xmlns="http://www.royalmailgroup.com/integration/core/V1">2</version>
<identification xmlns="http://www.royalmailgroup.com/integration/core/V1">
<applicationId>some random number</applicationId>
<transactionId>some reference number</transactionId>
</identification>
</integrationHeader>
</createShipmentRequest>
</s:Body>
</s:Envelope>
As you can see the namespaces are being outputted on the individual elements...
The working example I have has the namespaces defined in the SOAP Envelope;
<s:Envelope xmlns:v2="http://www.royalmailgroup.com/api/ship/V2" xmlns:v1="http://www.royalmailgroup.com/integration/core/V1" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header></s:Header>
<s:Body>
<v2:createShipmentRequest>
<v2:integrationHeader>
<v1:dateTime>2015-07-23</v1:dateTime>
<v1:version>2</v1:version>
<v1:identification>
<v1:applicationId>some random number</v1:applicationId>
<v1:transactionId>some reference number</v1:transactionId>
</v1:identification>
</v2:integrationHeader>
</v2:createShipmentRequest>
</s:Body>
</s:Envelope>
From what I understand this should not make a difference but the sever simply rejects the request. After modifying my generated request in SOAPUI it is defiantly this causing the problem, so how can I move the two namespace definitions v1 & v2 to the SOAP Envelope and then have the correct elements use the correct prefix?
My client is initiated using the following function;
private shippingAPIPortTypeClient GetProxy() {
BasicHttpBinding myBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
shippingClient = new shippingAPIPortTypeClient(myBinding, new EndpointAddress(new Uri(shippingClientSandboxEndpoint), EndpointIdentity.CreateDnsIdentity("api.royalmail.com"), new AddressHeaderCollection()));
shippingClient.ClientCredentials.ClientCertificate.Certificate = certificate;
return shippingClient;
}