繁体   English   中英

PHP的SOAP连接失败

[英]SOAP Connection failure with PHP

我正在尝试发出SOAP连接请求,但收到以下错误:

致命错误:SOAP错误:(错误代码:HTTP,错误字符串:无法连接到主机)

我正在尝试连接到客户端的Web服务,他们需要将我们连接到的服务器的IP地址白名单(已设置)。 但是,通过第三个肥皂客户端(例如SoapUI),它可以工作并给出成功的响应

这是我的代码:

$client = new SoapClient("test.wsdl", array('exceptions' => 0));
$result = $client->SendXMLLead();
if (is_soap_fault($result)) {
    trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
}

这是我们尝试连接的链接:

https://hqwarranty.com/hqwarranty-soap.php

我使用以下内容:

    $client = new SoapClient("live.wsdl");

$params = array(
   'Leads' => '',
            'RecordSequence' => 12345,
            'Date' => '02/26/2016',
            'TimeOfDay' => '3:25:33 PM',  
            'LastName' => 'test',
            'FirstName' => 'test',
            'EmailAddress' => 'test@test.com',
            'PhoneNumber' => '111-111-1111',
            'Zip' => 94539,
            'CellCode' => 'DTCPPCDA3P',
            'ClientId' => 'DTCB',
            'LeadType' => 'EMAIL',
            'Username' => 'CrossCountryLeadLoad',
);
$response = $client->__soapCall("SendXMLLead", array($params));

/* Print webservice response */
var_dump($response);

更新:

Fatal error: Uncaught SoapFault exception: [soap:Server] Validation failed for: com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchema@59109eda errors: [ org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'ShortTextRequired'., Line : 9, Column : 26 org.xml.sax.SAXParseException: cvc-type.3.1.3: The value '' of element 'DateTime' is not valid., Line : 9, Column : 26 org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'ShortTextRequired'., Line : 10, Column : 28 org.xml.sax.SAXParseException: cvc-type.3.1.3: The value '' of element 'FirstName' is not valid., Line : 10, Column : 28 org.xml.sax.SAXParseException: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'ShortTextRequired'., Line : 11, Column : 26 org.xml.sax.SAXParseException: cvc-type.3.1.3: The value '' of element 'LastName' is not val in

检查客户端定义。 验证失败通常与

肥皂版本不匹配(服务是否期望1.1,而您正在发送1.2?);

"soap_version"=>SOAP_1_1

或请求消息结构中的问题,请使用try / catch详细说明您的尝试;

try {
        $response = $soapClient->__soapCall('SendXMLLead', array('parameters' => $inputParams));
    } catch (SoapFault $fault) {
        echo "<pre>\n -- fault -- \n";
        var_dump($fault);
        echo "\n -- fault code/string --\n";
        echo "SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})";
        echo "\n -- request --\n";
        echo "REQUEST:\n" . htmlentities($soapClient->__getLastRequest()) . "\n";
        echo "\n -- response --\n";
        echo "Response:\n" . $soapClient->__getLastResponse() . "\n";
        echo "\n</pre>";
    }

这将为您提供所有消息语法,以便您可以与服务进行比较并检查结构,元素名称等是否存在任何错误...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM