views:

66

answers:

2

I generated a set of web service proxy objects with the .Net 3.5 svcutil.exe tool. The soap body element has 2 extraneous xml namespace alias declarations. Specifically schema and schema instance namespaces ( http://www.w3.org/2001/XMLSchema, http://www.w3.org/2001/XMLSchema-instance ).

For other reasons, the service I'm interacting with has a bug where these declarations can't be included. I'm trying to figure out how to remove them. Any help would be appreciated. The soap message looks something like this.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    ...
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      ...
    </s:Body>
</s:Envelope>
A: 

I don't think there's a way to do this, short of hand-writing your SOAP messages yourself. Those are just the usual XML schema namespaces and really shouldn't hurt, if they're not being used.

marc_s
Yea, I'm working on the service provider to fix their code but I don't have control over that. I am considering hand crafting it but I will lose all the flexibility, generated code, and capabilities of WCF doing that which I'm loathe to do.
Peter Oehlert
A: 

The solution I found was to implement a message inspector. I created a class that implements IClientMessageInspector. This class will get the opportunity to modify the message before it's sent on the wire or modify the response after it comes off the wire. I then create another class IEndpointBehavior which I use to register the custom message inspector. Finally I create a class that extends BehaviorExtensionElement to allow specifying the custom behavior in the configuration file.

With this solution, I am able to modify the message as it's being sent to the server and remove the offending xsi and xsd alias definitions.

Peter Oehlert