PHP:SOAP - 返回HTTP未找到

时间:2016-10-06 12:00:13

标签: php xml web-services soap

我遇到从PHP到.NET Web服务的SOAP调用问题。希望它是一个我想念的简单的东西,但是如果有人可以提供帮助,那就太棒了。肥皂电话如下:

// Start client:
$client = new SoapClient('http://connect7.gardners.com/priceavail.asmx?wsdl', array
(
    // Options:
    'trace' => 1
));

// Params:
$params = array(...)

// Call:
$response = $client->__soapCall("PriceAvailabilityRequest", array($params));

它会触发以下异常:

Fatal error: SOAP Fault: (faultcode: HTTP, faultstring: Not Found)

如果我在客户端上调用__getFunctions(),它将返回:

array(4) {
    [0]=> string(65) "Gardners_HelloResponse Gardners_Hello(Gardners_Hello $parameters)"
    [1]=> string(95) "PriceAvailabilityRequestResponse PriceAvailabilityRequest(PriceAvailabilityRequest $parameters)"
    [2]=> string(65) "Gardners_HelloResponse Gardners_Hello(Gardners_Hello $parameters)"
    [3]=> string(95) "PriceAvailabilityRequestResponse PriceAvailabilityRequest(PriceAvailabilityRequest $parameters)"
}

这是我在客户端调用__getLastRequest时生成的请求:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.bic.org.uk/webservices" xmlns:ns2="http://connect7.gardners.com/">
    <SOAP-ENV:Body>
        <ns2:PriceAvailabilityRequest>
            <ns2:PA_Request>
                <ns1:Header>
                    <ns1:ClientID>XXXXXX</ns1:ClientID>
                    <ns1:ClientPassword>XXXXXX</ns1:ClientPassword>
                    <ns1:AccountIdentifier>
                        <ns1:AccountIDType>02</ns1:AccountIDType>
                    </ns1:AccountIdentifier>
                    <ns1:SupplierIdentifier>
                        <ns1:SupplierIDType>02</ns1:SupplierIDType>
                    </ns1:SupplierIdentifier>
                    <ns1:SupplierRegionsCoded>
                         <ns1:SupplierRegionCodeType>01</ns1:SupplierRegionCodeType>
                    </ns1:SupplierRegionsCoded>
                    <ns1:CurrencyCode>GBP</ns1:CurrencyCode>
                </ns1:Header>
                <ns1:Product>
                    <ns1:EAN13>9780007185580</ns1:EAN13>
                    <ns1:ProductIdentifier>
                        <ns1:ProductIDType>15</ns1:ProductIDType>
                    </ns1:ProductIdentifier>
                </ns1:Product>
            <ns2:PA_Request>
        </ns2:PriceAvailabilityRequest>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

以下是来自webservice文档的示例请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="http://connect7.gardners.com/" xmlns:web="http://www.bic.org.uk/webservices">
    <soapenv:Header/> 
    <soapenv:Body>
        <con:PriceAvailabilityRequest>
            <con:PA_Request version="1.2">
                <web:Header>
                    <web:ClientID>XXXXXXX</web:ClientID>
                    <web:ClientPassword>XXXXXX</web:ClientPassword>
                    <web:AccountIdentifier>
                        <web:AccountIDType>02</web:AccountIDType> 
                    </web:AccountIdentifier>
                    <web:SupplierIdentifier>
                        <web:SupplierIDType>02</web:SupplierIDType> 
                    </web:SupplierIdentifier> 
                    <web:SupplierRegionsCoded>
                       <web:SupplierRegionCodeType>01</web:SupplierRegionCodeType> 
                    </web:SupplierRegionsCoded> 
                    <web:CurrencyCode>GBP</web:CurrencyCode>
                </web:Header>
                <web:Product>
                    <web:EAN13>9780762444205</web:EAN13> 
                    <web:ProductIdentifier>
                        <web:ProductIDType>15</web:ProductIDType> 
                    </web:ProductIdentifier>
                </web:Product> 
            </con:PA_Request>
        </con:PriceAvailabilityRequest> 
    </soapenv:Body>
</soapenv:Envelope>

我已经尝试了解导致错误的原因&#39; Not Found&#39;但是没有找到具体的东西。从我发现的名称空间的差异不应该导致问题?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

Faultcode“HTTP”和Faultstring“Not Found”表示您的客户端无法访问服务器(端点)。

WSDL可用,但似乎服务端点http://connect7.gardners.com/PriceAvail/priceavail.asmx不是。