开发者

Extraneous wcf body xml namespace declarations

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:Enve开发者_Python百科lope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    ...
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      ...
    </s:Body>
</s:Envelope>


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜