如何改变在WCF的SOAP信封模式? [英] How do you change the SOAP Envelope schema in WCF?

查看:283
本文介绍了如何改变在WCF的SOAP信封模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我连接到通过WCF第三方终点,我有一个问题。对于由WCF生成的SOAP信封的模式是不与终点兼容。

I am connecting to a third-party end point via WCF and I have one problem. The schema for the SOAP envelope that is generated by WCF isn't compatible with the end point.

目前WCF是产生这样的:

Currently WCF is generating this:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">

但它必须是这样的:

But it needs to be this:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing">

我测试过这一点的soapUI,以确认这是问题,但我怎么能在WCF控制呢?我使用的添加服务引用选项在Visual Studio生成服务。

I've tested this in soapUI to confirm this is the problem, but how can I control this in WCF? I used the Add Service Reference option in Visual Studio to generate the service.

任何想法?

在此先感谢。

刘德华

推荐答案

最有可能的,你有一个问题,与SOAP版本。您使用的是??

Most likely, you have an issue with the SOAP version. What binding are you using??

basicHttpBinding的默认为SOAP 1.1,而的wsHttpBinding 默认为SOAP 1.2

basicHttpBinding defaults to SOAP 1.1, while wsHttpBinding defaults to SOAP 1.2

这是SOAP 1.1(默认basicHttpBinding的):

This is SOAP 1.1 (default in basicHttpBinding):

<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

而这是SOAP 1.2(默认的wsHttpBinding):

while this is SOAP 1.2 (default in wsHttpBinding):

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">

可能的解决方案:

1)或者你可以切换绑定,这一切有 - 你需要确保检查安全设置等(基本的和的wsHttpBinding)

1) either you can just switch bindings and that's all there is - you need to make sure to check for security settings and so on (which differ between basic and wsHttpBinding)

2),你需要创建自己的自定义绑定,并明确指定所需的SOAP版本

2) you need to create your own custom binding and explicitly specify the SOAP version you need

这篇关于如何改变在WCF的SOAP信封模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆