I am trying to make a SOAP connection request, but receive the following error:
Fatal error: SOAP Fault: (faultcode: HTTP, faultstring: Could not connect to host)
I am attempting to connect to a client's web-service and they needed to whitelist the IP address of the server from where we are connecting to(which is already set). However, through a 3rd soap client such as SoapUI, it works and gives a successful response
Here is my code:
$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);
}
Here is the link from where we are trying to connect:
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
答案 0 :(得分:0)
检查客户端定义。验证失败通常与
有关肥皂版本不匹配(服务期待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>";
}
这将为您提供所有消息语法,以便您可以与服务进行比较,并检查结构,元素名称等中的任何错误......