当我从 gsoap 调用在 IIS 7.5 中运行的 Web 服务时,为什么会收到 HTTP 400 错误?
我正在尝试调用在 IIS 7.5 内的 Windows 7 计算机上运行的 Web 服务。我可以使用soapUI从本地计算机调用Web服务,并从另一台计算机调用Java客户端,并且它可以工作。当我尝试在 C 程序中使用 gsoap 框架从远程计算机调用 Web 服务时,我收到 HTTP 400:错误请求。我的请求/响应如下,有什么想法吗?
POST /MyService/AddressService.asmx HTTP/1.1
Host: thisMachine.myDomain.net
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 714
Connection: close
SOAPAction: "http://thisMachine.myDomain.net/MyService/AddressService.asmx/CheckAddress"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope>
<SOAP-ENV:Body>
<AddressService1:CheckAddress>
<AddressService1:chkAddress>
<AddressService1:chkCompanyName>Test</AddressService1:chkCompanyName>
<AddressService1:chkStreet1>123 Some Rd</AddressService1:chkStreet1>
<AddressService1:chkStreet2></AddressService1:chkStreet2>
<AddressService1:chkCity>Columbia</AddressService1:chkCity>
<AddressService1:chkState>SC</AddressService1:chkState>
<AddressService1:chkZipcode5>29054</AddressService1:chkZipcode5>
<AddressService1:chkZipcode4></AddressService1:chkZipcode4>
<AddressService1:chkSuite></AddressService1:chkSuite>
</AddressService1:chkAddress>
</AddressService1:CheckAddress>
</SOAP-ENV:Body>
HTTP/1.1 400 Bad Request
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Mon, 29 Aug 2011 19:46:55 GMT
Connection: close
Content-Length: 0
I am trying to call a web service running on a Windows 7 machine inside of IIS 7.5. I can call the web service from the local machine using soapUI and a Java client from another machine and it works. When I try to call the web service from a remote machine using the gsoap framework in a C program, I get an HTTP 400: Bad Request. My request/response is below, any ideas?
POST /MyService/AddressService.asmx HTTP/1.1
Host: thisMachine.myDomain.net
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 714
Connection: close
SOAPAction: "http://thisMachine.myDomain.net/MyService/AddressService.asmx/CheckAddress"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope>
<SOAP-ENV:Body>
<AddressService1:CheckAddress>
<AddressService1:chkAddress>
<AddressService1:chkCompanyName>Test</AddressService1:chkCompanyName>
<AddressService1:chkStreet1>123 Some Rd</AddressService1:chkStreet1>
<AddressService1:chkStreet2></AddressService1:chkStreet2>
<AddressService1:chkCity>Columbia</AddressService1:chkCity>
<AddressService1:chkState>SC</AddressService1:chkState>
<AddressService1:chkZipcode5>29054</AddressService1:chkZipcode5>
<AddressService1:chkZipcode4></AddressService1:chkZipcode4>
<AddressService1:chkSuite></AddressService1:chkSuite>
</AddressService1:chkAddress>
</AddressService1:CheckAddress>
</SOAP-ENV:Body>
HTTP/1.1 400 Bad Request
Cache-Control: private
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Mon, 29 Aug 2011 19:46:55 GMT
Connection: close
Content-Length: 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我忘了提及我正在 OpenVms 上运行 GSOAP。事实证明,这很重要,因为 gSoap 已移植到 OpenVms,并且该移植中似乎可能存在错误。似乎发生的事情是我将 -n 选项与 WSDL2H 一起使用,并指定了要在生成 gsoap 客户端源文件时使用的命名空间。生成的 .nsmap 文件中的命名空间数组将我的命名空间附加到数组的名称中,这会在引用数组时导致问题(一旦我更改了 make(命令过程)以显示警告,这会在编译时显示为警告) ;由于无法引用数组,因此命名空间被排除在 SOAP 文档之外,这对于 .Net Web 服务来说是不可接受的,并导致 HTTP 400 - 错误请求错误。为了解决这个问题,我将命名空间数组的名称更改为“namespaces”,这修复了 SOAP 文档的生成方式。
I forgot to mention that I am running GSOAP on OpenVms. This turns out to be significant because gSoap was ported to OpenVms and it appears there may have been an error in the port. What seems to be going on is that I used the -n option with WSDL2H and specified a namespace to be used in the generation of the gsoap client source files. The array of namespaces in the generated .nsmap file had my namespace appended to the array's name which causes issues when the array is being referenced (this showed up as a warning at compile time once I changed my make (command procedure) to show warnings); since the array couldn't be referenced, the namespaces where left out of the SOAP document and this was unacceptable to the .Net web service and resulted in an HTTP 400 - Bad Request error. To get this fixed, I changed the name of the namespace array to 'namespaces' which fixed how the SOAP documents were generated.