douyun3022
douyun3022
2013-01-08 19:46

AllPosters.com SOAP有问题的响应

已采纳

I have a problem with the allposters.com SOAP (http://webservice.allposters.com/). I am trying to fetch some product information via (a slightly modified) nuSOAP PHP library (http://sourceforge.net/projects/nusoap/) on a PHP 5.3 installation.

My request is (all the characters are exactly like here, they are not converted to entities):

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>

And I get the error

Length cannot be less than zero. Parameter name: length

in this specific response

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>

The communication seems to be working fine; if I remove the "WebSiteID" element from my previous request, I would get

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

Unfortunatelly, from the few examples I found on the web and from a 7-pages document on their website with a sample in Visual Basic (this is the only documentation I was able to find), I really can't figure out what I am missing, and that .NET error doesn't tell me something I can use.

Did someone experienced similar problems with the allposters.com affiliate webservice and have some advice?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • duan41497 duan41497 8年前

    You are using the Soap service in the wrong way.

    If you look at the example on the page for the call "GetProductByProductNumberInformation" on http://webservice.allposters.com/ProductInformationService.asmx?op=GetProductByProductNumberInformation there is only a placeholder "string" mentioned, but you are sending a complete set of XML. This is probably wrong.

    I don't know why you think you can send more than a string like the XML you did, but I found out that this service actually expects you to send your XML wrapped inside a CDATA so that it is just a string - the server then unpacks the string and does another XML parsing.

    This implementation method is completely bullshit, because it circumvents the point of having a Soap Service with a WSDL description of what kind of parameters the service allows and expects - but you are most unlikely to change that.

    So you have to make NuSoap to wrap your XML string inside CDATA tags, otherwise it won't work at all, I think.

    点赞 评论 复制链接分享
  • dqvrlgi3247 dqvrlgi3247 8年前

    The OP offered the following solution in a question edit, so I am moving to an answer proper:

    <?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>
    
    点赞 评论 复制链接分享

相关推荐