.NET 客户端“格式不正确” 来自 Axis Web 服务的 XML 响应

发布于 2024-07-23 07:25:46 字数 1202 浏览 3 评论 0原文

我有一个简单的 .NET 应用程序,它对第三方 Axis Web 服务进行 SOAP 调用。 当我跟踪 HTTP 流量时,我发现请求看起来不错,但出现了异常:“响应不是格式良好的 XML。” 返回对象为 null,因为 XML 似乎无法反序列化。

关于 wsdl 中的各种名称空间声明的一个问题。 其中一些声明指向不再存在的 URL/域。 这会导致任何问题吗?

来自 wsdl 文档:

<wsdl:definitions targetNamespace="http://domaindoesntexist.com/"  
xmlns:apachesoap="http://xml.apache.org/xml-soap"  
xmlns:impl="http://domaindoesntexist.com/"  
xmlns:intf="http://domaindoesntexist.com/"  
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"  
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

删除了有罪数据的示例 HTTP 响应:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Fri, 05 Jun 2009 13:54:59 GMT

7cb
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<someMethod xmlns="http://test.com/services/myservice/">
</someMethod>
</soapenv:Body>
</soapenv:Envelope>
0

I have a simple .NET app that makes a SOAP call to a third party Axis web service. When I trace the HTTP traffic, I see that the Request looks fine, however I'm getting an exception: "Response is not well-formed XML." The return object is null, as it seems the XML can't be deserialized.

One question regarding the various namespace declarations inside the wsdl. Several of these declarations point to URLs / domains that no longer exist. Could this cause any problems?

From the wsdl document:

<wsdl:definitions targetNamespace="http://domaindoesntexist.com/"  
xmlns:apachesoap="http://xml.apache.org/xml-soap"  
xmlns:impl="http://domaindoesntexist.com/"  
xmlns:intf="http://domaindoesntexist.com/"  
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"  
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

A sample HTTP response with incriminating data removed:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Fri, 05 Jun 2009 13:54:59 GMT

7cb
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<someMethod xmlns="http://test.com/services/myservice/">
</someMethod>
</soapenv:Body>
</soapenv:Envelope>
0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心的憧憬 2024-07-30 07:25:46

根据我的经验,名称空间 URL 不必是实际存在的 URI。我们需要的是一致性,因此可以构建内部 XML 架构来进行验证。 (我相信)其目的是在该位置托管命名空间定义,以便开发人员可以去那里检查它,但后来人们变得懒惰了。

事实上,我在后一点上可能是完全错误的。

It has been my experience that namespace URLs do not have to be actual existing URIs. Consistency is what is desired, so internal XML schemas can be built for validation. The intent was (I believe) to host the namespace definition at that location so that developers could go there and check it out, but then people got lazy.

I may, in fact, be quite wrong on that latter count.

半世晨晓 2024-07-30 07:25:46

其中一些声明指向
不再存在的 URL/域。
这会导致任何问题吗?

当然。 您是否尝试过更新项目中的网络服务?

Several of these declarations point to
URLs / domains that no longer exist.
Could this cause any problems?

Sure. Have you tried updating the webservice in your project?

哑剧 2024-07-30 07:25:46

我遇到了类似的问题,在查看 Wireshark 跟踪后发现有一个代理服务器正在 XML 有效负载中插入一些标头

Web 服务正在尝试加载 xml

"Content-Type: text/xml;charset=utf -8
变化:接受编码、用户代理
连接:关闭
传输编码:分块
2rZ3fnB2rMzDjipXgQz8ObOcEczeOIO74sa17YK5hrPkt62qce12BItOmuvPrC/WD8N3xZzBeBceBbiAA0IlsR2aXxd479Es7wO9va2cGpF/cc284gI.K5FXbOR5PUPx00EqNRjCdbdU4f v/JXN2alGDzGVlgCnRK5/6DJlAkcED2011-06-08T15:35:21.505Z"

显然不会加载。

我的情况下的完整 TCP 流

POST /ls/ws /auth HTTP/1.1

用户代理:Mozilla/4.0(兼容;MSIE 6.0;MS Web 服务客户端协议 2.0.50727.3615)

内容类型:text/xml;charset=utf-8

SOAPAction:""

主机:???? ??

内容长度:487

期望:100 继续

连接:保持活动

2PUldqLs2KqUkJryFiZPQJI.D6RCixeMu443SLd7dCF2qrzws0E2JYatTqm8wD2CuFrSVHEjvJHIXfiLy6w9yBagentfp093.0.1.9019HTTP/1.0 200 确定

日期: 2011 年 6 月 8 日星期三 15:35:21 GMT

服务器:Apache-Coyote/1.1

内容-类型:text/xml;charset=utf-8

变化:Accept-Encoding、User-Agent

X-Cache:来自 dgtproxy1.skybroadband.com.ph 的 MISS

连接:close

.1

内容类型:text/xml;charset=utf- 8

变化:接受编码,用户代理

连接:关闭

传输编码:分块

2rZ3fnB2rMzDjipXgQz8ObOcEczeOIO74sa17YK5hrPkt62qce12BItOmuvPrC/WD8N3xZzBeBceBbiAA0IlsR2aXxd479Es7wO9va2cGpF/cc284 GI.K5FXbOR5PUPx00EqNRjCdbdU4fv/JXN2alGDzGVlgCnRK5/6DJlAkcED2011-06-08T15:35:21.505Z

I had a similar problem and after looking into Wireshark trace it was found that there is a Proxy server which is inserting some headers in the XML payload

webservice is trying to load xml

"Content-Type: text/xml;charset=utf-8
Vary: Accept-Encoding,User-Agent
Connection: close
Transfer-Encoding: chunked
2rZ3fnB2rMzDjipXgQz8ObOcEczeOIO74sa17YK5hrPkt62qce12BItOmuvPrC/WD8N3xZzBeBceBbiAA0IlsR2aXxd479Es7wO9va2cGpF/cc284gI.K5FXbOR5PUPx00EqNRjCdbdU4fv/JXN2alGDzGVlgCnRK5/6DJlAkcED2011-06-08T15:35:21.505Z"

which obviously will not load.

The complete tcp stream in my case

POST /ls/ws/auth HTTP/1.1

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3615)

Content-Type: text/xml; charset=utf-8

SOAPAction: ""

Host: ??????

Content-Length: 487

Expect: 100-continue

Connection: Keep-Alive

2PUldqLs2KqUkJryFiZPQJI.D6RCixeMu443SLd7dCF2qrzws0E2JYatTqm8wD2CuFrSVHEjvJHIXfiLy6w9yBagentfp093.0.1.9019HTTP/1.0 200 OK

Date: Wed, 08 Jun 2011 15:35:21 GMT

Server: Apache-Coyote/1.1

Content-Type: text/xml;charset=utf-8

Vary: Accept-Encoding,User-Agent

X-Cache: MISS from dgtproxy1.skybroadband.com.ph

Connection: close

.1

Content-Type: text/xml;charset=utf-8

Vary: Accept-Encoding,User-Agent

Connection: close

Transfer-Encoding: chunked

2rZ3fnB2rMzDjipXgQz8ObOcEczeOIO74sa17YK5hrPkt62qce12BItOmuvPrC/WD8N3xZzBeBceBbiAA0IlsR2aXxd479Es7wO9va2cGpF/cc284gI.K5FXbOR5PUPx00EqNRjCdbdU4fv/JXN2alGDzGVlgCnRK5/6DJlAkcED2011-06-08T15:35:21.505Z

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文