AllPosters.com SOAP有问题的响应

时间:2013-01-08 19:46:12

标签: php soap nusoap

我遇到了allposters.com SOAP(http://webservice.allposters.com/)的问题。我试图通过(一个稍微修改过的)nuSOAP PHP库(http://sourceforge.net/projects/nusoap/)在PHP 5.3安装上获取一些产品信息。

我的要求是(所有字符都在这里,它们不会转换为实体):

POST /ProductInformationService.asmx HTTP/1.0
Host: webservice.allposters.com
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://Webservice.Allposters.com/APCF.AffiliateWebService/ProductInformationService/GetProductByProductNumberInformation"
Content-Length: 570

<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <GetProductByProductNumberInformation xmlns="http://Webservice.Allposters.com/APCF.AffiliateWebService/ProductInformationService">
            <APCSearchXml>
                <WebSiteID>1234567890</WebSiteID>
                <SearchTerm>1234567</SearchTerm>
                <LanguageID>1</LanguageID>
                <CurrencyCode>USD</CurrencyCode>
            </APCSearchXml>
        </GetProductByProductNumberInformation>
    </soap:Body>
</soap:Envelope>

我收到错误

Length cannot be less than zero. Parameter name: length

在此特定回复中

HTTP/1.1 200 OK
Connection: keep-alive
Date: Tue, 08 Jan 2013 18:46:59 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 821

<APC_Search_Results>
   <StatusCode>1</StatusCode>
   <Search_Error>
       <ErrorNumber>1</ErrorNumber>
       <ErrorDescription>Length cannot be less than zero. Parameter name: length</ErrorDescription>
   </Search_Error>
</APC_Search_Results>

沟通似乎运作良好;如果我从我之前的请求中删除“WebSiteID”元素,我会得到

Index was out of range. Must be non-negative and less than the size of the collection.

不幸的是,从我在网上找到的几个例子和他们网站上的7页文档以及Visual Basic中的一个示例(这是我能找到的唯一文档),我真的无法弄清楚我错过了什么,.NET错误并没有告诉我一些我可以使用的东西。

是否有人遇到过与allposters.com联盟网络服务类似的问题并提出一些建议?

2 个答案:

答案 0 :(得分:2)

您正在以错误的方式使用Soap服务。

如果您查看页面上http://webservice.allposters.com/ProductInformationService.asmx?op=GetProductByProductNumberInformation上调用“GetProductByProductNumberInformation”的示例,则只提及占位符“字符串”,但您要发送一整套XML。这可能是错误的。

我不知道为什么你认为你可以发送超过你所做的XML之类的字符串,但我发现这个服务实际上希望你发送你的XML包装在CDATA中,这样它只是一个字符串 - 然后服务器解压缩字符串并进行另一次XML解析。

这种实现方法完全是废话,因为它绕过了Soap Service的问题,该服务具有WSDL描述服务允许和期望的参数类型 - 但是你最不可能改变它。

所以你必须让NuSoap将你的XML字符串包装在CDATA标签内,否则我认为它根本不起作用。

答案 1 :(得分:0)

OP在问题编辑中提供了以下解决方案,因此我正在寻求答案:

<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <GetProductByProductNumberInformation xmlns="http://Webservice.Allposters.com/APCF.AffiliateWebService/ProductInformationService">
            <APCSearchXml>
                <![CDATA[ 
                  <APC_Search_Query>
                        <WebSiteID>1234567890</WebSiteID>                        
                            <SearchText>123456</SearchText>
                        <LanguageID>1</LanguageID>
                        <CurrencyCode>USD</CurrencyCode>
                  </APC_Search_Query>
                ]]>
            </APCSearchXml>
        </GetProductByProductNumberInformation>
    </soap:Body>
</soap:Envelope>