如何获得消息的合​​同,发送SOAP动作的身体,而不是头部 [英] How to get message contract to send soap action in body and not header

查看:177
本文介绍了如何获得消息的合​​同,发送SOAP动作的身体,而不是头部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用/ messageContract在我的SvcUtil工具命令,我的SOAP消息发送SOAP信封的报头中的动作或操作,而不是身体。远程端点是一个供应商的基于Java的服务,在这我管不着。

我需要的行动,在正文中发送,但仍使用/ messageContract。

有谁知道如何实现这一目标?

SOAP信封

 < S:信封XMLNS:S =htt​​p://schemas.xmlsoap.org/soap/envelope/>
< S:头>
<作用S:mustUnderstand属性=1的xmlns =htt​​p://schemas.microsoft.com/ws/2005/05/addressing/none>获得性能< /作用>
< / S:头>
< S:身体的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instance的xmlns:XSD =htt​​p://www.w3.org/2001/XMLSchema>< / S:车身>
< / S:信封>
 

SOAP信封的

 < S:信封XMLNS:S =htt​​p://schemas.xmlsoap.org/soap/envelope/>
< S:头>< / S:头>
< S:身体的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instance的xmlns:XSD =htt​​p://www.w3.org/2001/XMLSchema>
<获得性能的xmlns =htt​​p://www.opengis.net/cat/csw/2.0.2>< /获得性能>
< / S:车身>
< / S:信封>
 

我的SvcUtil工具命令:

  SvcUtil工具/目标:code HTTP://localhost/sarpilo​​t/xml/mywisdl.wsdl / messageContract /out:WebService.cs /config:WebService.config
 

解决方案

真正确定你的目标(基于Java)的Web服务需要在SOAP体,而不是SOAP头一个基于Microsoft的命名空间元素?这似乎是假的我。

 <作用S:mustUnderstand属性=1的xmlns =htt​​p://schemas.microsoft.com/ws/2005/05/addressing/none>获得性能< /作用>
 

大多数Web服务只需要行动在HTTP头文件,还不如SOAP主体的一部分:

  POST /股票报价HTTP / 1.1
内容类型:text / xml的;字符集=utf-8
内容长度:NNNN
SOAPAction报:http://electrocommerce.org/abc#MyMessage

< SOAP-ENV:信封...
 

你能提供一个原始的,工作的SOAP请求(包括HTTP标头)进行比较? 最简单的SOAP例如:你可以用这个小基于网页的客户端测试它独立于.NET使用Javascript 。我想从您的其他发布<一个href="http://stackoverflow.com/questions/5460107/soap-xml-response-received-but-not-populating-response-object">here这显示了工作的要求,你真的不需要微软动作元素在你的SOAP体。

When i use the "/messageContract" in my svcutil command, my soap message sends the action or operation in the header of the soap envelope and not the body. The remote endpoint is a vendor's Java based service which i have no control over.

I need the action to to be sent in the body but still use "/messageContract".

Does anyone know how to achieve this?

SOAP envelope WITH "/messageContract"

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">GetCapabilities</Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"></s:Body>
</s:Envelope>

SOAP envelope WITHOUT "/messageContract"

<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">
<GetCapabilities xmlns="http://www.opengis.net/cat/csw/2.0.2"></GetCapabilities>
</s:Body>
</s:Envelope>

my svcutil command:

svcutil /target:code http://localhost/sarpilot/xml/mywisdl.wsdl /messageContract /out:WebService.cs /config:WebService.config

解决方案

Are truly sure your target (Java-based) web service requires a Microsoft-based namespace element in the SOAP body instead of the SOAP header? That seems bogus to me.

<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">GetCapabilities</Action>

Most web services only need the Action in the HTTP header, not as part of the SOAP body:

POST /StockQuote HTTP/1.1
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: "http://electrocommerce.org/abc#MyMessage"

<SOAP-ENV:Envelope...

Can you provide a raw, working SOAP request (including HTTP headers) for comparison? You can test it out independent from .NET by using this little web-page based client: Simplest SOAP example using Javascript. I assume from your other posting here which shows a "working" request that you really don't need the Microsoft Action element in your SOAP body.

这篇关于如何获得消息的合​​同,发送SOAP动作的身体,而不是头部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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