I have a .NET client calling into a SOAP .asmx web service. The client I’m developing is itself a WCF service under .NET 4. The destination .asmx web service is a Service Reference in the application. I don’t have any control over the destination.
The problem is that when calling a web service, the XML that is created for the call doesn’t include a particular namespace in the root element of the serialized XML of the proxy classes being sent.
Rather, it applies the namespace for a handful of elements nested within the document.
When using the proxy classes:
var x = new RemoteService_PortTypeClient();
x.SomeMethod(somePayload);
The destination service returns an exception when formatted with the hl7 namespace throughout:
Could not find schema information for the element ‘urn:hl7-org:v3:typeId’.
The current serialized proxy object (somePayload) is being sent as:
<MyRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
....
<MyNode value="20120801100803" xmlns="urn:hl7-org:v3" />
How I’d like it to be sent:
<MyRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:hl7-org:v3">
....
<MyNode value="20120801100803" />
How can I force my client to declare the namespace in the root, rather than being scattered in the element?
I know that having this namespace in the root will be accepted without error by the service, as it’s been demonstrated to work in that way.
Are there declarations/attributes in References.cs or web.config or other to force this?
I solved my own issue by creating a Web Reference instead of a Service Reference.