Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP cURL提交到WSDL SOAP环境_Php_Soap_Wsdl - Fatal编程技术网

PHP cURL提交到WSDL SOAP环境

PHP cURL提交到WSDL SOAP环境,php,soap,wsdl,Php,Soap,Wsdl,我从来没有机会提交到WSDL SOAP web服务,现在遇到了一些问题。我使用PHPCURL将表单提交到已知的后端,然后再提交到WSDLSOAP服务。第一部分工作正常,所以我将跳过它。我花了3天的大部分时间尝试在web上找到的不同解决方案,以及在阅读SOAP文档后找到的自己的解决方案,但运气不佳 下面是我用来提交到WSDL的内容 <?php //first cURL POST HERE - works fine //second cURL POST BELOW $F

我从来没有机会提交到WSDL SOAP web服务,现在遇到了一些问题。我使用PHPCURL将表单提交到已知的后端,然后再提交到WSDLSOAP服务。第一部分工作正常,所以我将跳过它。我花了3天的大部分时间尝试在web上找到的不同解决方案,以及在阅读SOAP文档后找到的自己的解决方案,但运气不佳

下面是我用来提交到WSDL的内容

<?php
    //first cURL POST HERE - works fine
    //second cURL POST BELOW
    $FName          = $_POST['FirstName'];
    $Lname          = $_POST['LastName'];
    $Email          = $_POST['Email'];
    $Phone          = $_POST['Phone1'];
    $soapURL            = "https://something.com/IBWeb/IBDemoManager/IBDemoManager.asmx?wsdl";
    $soapUser           = "USR";
    $soapPassword       = "PWD";
    $hostname           = gethostbyaddr($_SERVER['REMOTE_ADDR']);

    $xml_post_string = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.htdocs.openecry">
                          <soapenv:Header/>
                           <soapenv:Body>
                              <web:demosetup soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
                                 <AccessCode xsi:type="xsd:string">G0!=@%fut40</AccessCode>
                                 <NewUserCategoryName xsi:type="xsd:string">OFLDemo</NewUserCategoryName>
                                 <TemplateUserName xsi:type="xsd:string">OFLUser</TemplateUserName>
                                 <CusType xsi:type="xsd:string">Indirect</CusType>
                                 <WLabelID xsi:type="xsd:string">276</WLabelID>
                                 <SCodeID xsi:type="xsd:string"></SCodeID>
                                 <SoftID xsi:type="xsd:string">1</SoftID>
                                 <FName xsi:type="xsd:string">'.$FName.'</FName>
                                 <LName xsi:type="xsd:string">'.$LName.'</LName>
                                 <Email xsi:type="xsd:string">'.$Email.'</Email>
                                 <Phone xsi:type="xsd:string">'.$Phone.'</Phone>
                                 <Address xsi:type="xsd:string"></Address>
                                 <City xsi:type="xsd:string"></City>
                                 <Zip xsi:type="xsd:string"></Zip>
                                 <State xsi:type="xsd:string"></State>
                                 <Country xsi:type="xsd:string"></Country>
                                 <CountryName xsi:type="xsd:string"></CountryName>
                                 <AssetTypes xsi:type="xsd:string">Futures</AssetTypes>
                                 <How xsi:type="xsd:string">OFL webservice</How>
                                 <MoreEmail xsi:type="xsd:string"></MoreEmail>
                                 <RemoteAddr xsi:type="xsd:string">'.$hostname.'</RemoteAddr>
                                 <CampaignID xsi:type="xsd:string"></CampaignID>
                              </web:demosetup>
                           </soapenv:Body>
                        </soapenv:Envelope>';

    $headers = array(
        "Content-type: text/xml;charset=\"utf-8\"",
        "Accept: text/xml",
        "Cache-Control: no-cache",
        "Pragma: no-cache",
        //IS SOAPAction the same as the endpoint "$soapURL"?//
        "SOAPAction: https://something.com/IBWeb/IBDemoManager/IBDemoManager.asmx?wsdl", 
        "Content-length: ".strlen($xml_post_string),
    );

    $url2 = $soapURL;
    $soap_do = curl_init();
      curl_setopt($soap_do, CURLOPT_URL, $url2 );
      curl_setopt($soap_do, CURLOPT_HEADER, false);
      curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 100);
      curl_setopt($soap_do, CURLOPT_TIMEOUT,        100);
      curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
      curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
      curl_setopt($soap_do, CURLOPT_POST,           true );
      curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $xml_post_string);
      curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $headers);
      if(curl_exec($soap_do) === false) {
        $err = 'Curl error: ' . curl_error($soap_do);
        curl_close($soap_do);
        print $err;
      } else {
        $result = curl_exec($soap_do);
        echo '<pre>';
        print_r($result);
        curl_close($soap_do);
        //print 'Operation completed without any errors';
      }

以下是一些评论:

尝试禁用SSL检查(仅用于测试):

您应该调用
curl\u close($ch2)作为最后一个。例如:

$output2=curl\u exec($ch2);
如果(旋度误差($ch2))
回波旋度误差($ch2);
}否则{
echo$output2;
}

卷曲关闭($ch2);//<我遇到了一些问题
。请您添加有关错误消息的更多详细信息,我无法从Web服务获得任何信息,或者我没有正确设置以显示它。我只是在控制台中显示我提交的内容,所以我知道它与我希望提交的内容匹配。我更新了w/代码以显示返回的错误。我得到了一个大的xml包装,最后一行是“结果错误:重复用户帐户!”这很奇怪,因为我使用的是一个虚构的电子邮件地址谢谢。我更新了我的请求并从服务中返回了错误,它被挂在了一个重复的帐户上。这是不可能的,因为我正在填写测试的电子邮件地址。我也会测试你的建议
curl_setopt($ch2, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, 0);
$output2 = curl_exec($ch2); 

if(curl_errno($ch2))
    echo curl_error($ch2);
} else {
    echo $output2;
}

curl_close($ch2); // <--- close here