我希望调用一系列 SOAP 服务(跨一系列服务),虽然端点已明确定义并且可以在多个端点之间进行调用。已记录,没有 WSDL 数据...所以我决定构建自己的。
为此,我构建了一个测试 WCF 服务,该服务与我希望调用的服务的已知接口相匹配。
然后,我保存了它公开的 WSDL,更改了 WSDL 引用的基地址,创建了我的代理(使用 wsdl.exe),将其添加到测试客户端项目中,并且可以成功创建代理并进行调用,从而导致 SOAP 服务发送预期响应...只有此预期响应不会被代理拾取并返回到调用代码。
当查看来回流量时......我可以清楚地看到该服务正在回复我想要的内容。
关于如何解决此问题并让代理获取数据有什么建议吗?
鉴于回复实际上是相同的,我被迫回顾我的客户端发送的内容与另一个客户端发送的内容之间的差异发送。
一个已知的工作应用程序发送其 XML blob,开头如下:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
而我的客户端立即以信封开头(没有 xml 标记,并且少了一个命名空间):
另一个区别是正文中的消息以他们的命名空间为前缀,而我的则不是......尽管两者都在其中定义了此命名空间标签。
阿拉:
<s:Body>
<u:DoSomething xmlns:u="urn:http://some.namespace.org" />
</s:Body>
VS:
<s:Body>
<DoSomething xmlns="urn:http://some.namespace.org" />
</s:Body>
There is a series of SOAP services which I wish to call (across a series of services), and while the end points are well defined & documented, there is no WSDL data... so I decided to build my own.
In order to do so, I built a test WCF service which matches the known interface of the service I wish to call.
I then saved the WSDL it exposed, changed the base address the WSDL references, created my proxy (with wsdl.exe), added it to a test client project, and can successfully create a proxy and make calls which causes the SOAP service to send the expected response... only this expected response is not picked up by the proxy and returned to the calling code.
When looking at the back and forth traffic... I can clearly see that the service is replying with what I want.
Any suggestions as to how I might troubleshoot this and get the proxy to pickup the data?
Given the replies are effectively identical, I'm forced to look back at the differences between what my client is sending and another sends.
A known working app sends it's XML blob starting with the following:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
While my client immediately starts with the envelope (without the xml tag, and with one less namespace):
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
The other difference is that the message within the body is prefixed by a namespace in theirs, while mine it is not... though both define this namespace within the tag.
Ala:
<s:Body>
<u:DoSomething xmlns:u="urn:http://some.namespace.org" />
</s:Body>
VS:
<s:Body>
<DoSomething xmlns="urn:http://some.namespace.org" />
</s:Body>
发布评论
评论(2)
这不是命名空间:
它正在设置信封的编码样式,尽管它不是必需的 根据 SOAP 规范,可能是您正在讨论的特定实现所需要的。您是否对从客户端发送的内容有足够的控制权以将其发送到那里?
除此之外,XML PI 不是必需的,我认为您在查看正文 XML 时绝对是在正确的轨道上。这几乎总是某种名称空间不匹配的情况。您是否 100% 肯定命名空间 URI 是相同?
This is not a namespace:
It's setting the encoding style for the envelope which, even though it's not required per the SOAP spec, may be required by the specific implementation you're talking to. Do you have enough control over what you're sending from the client to get that put on there?
Other than that, the XML PI is not required and I think you're definitely on the right track looking at the body XML. This is almost always the case of some kind of namespace mismatch somewhere. Are you 100% positive the namespace URIs are identical?
最可能的问题是使用“默认”XML 命名空间的 VS 版本。我工作过的一些肥皂解析器在使用非别名(默认)命名空间时无法正常工作。如果您知道使用 u: 别名可与该服务配合使用,则即使 s:Body 元素内的每个标记都以别名作为前缀,您的代理也应该生成它。
The most likely problem is the VS version using a "default" XML namespace. There are soap parsers that I've worked which don't work correctly when using an un-aliased (default) namespaces. If you know using the u: alias works with the service, your proxy should also generate it even when every tag inside the s:Body element is prefixed with the alias.