如何通过php将xmldata发布到https://wsdl

如何通过php将xmldata发布到https://wsdl,php,Php,大家晚上好 我一直在努力将xml数据发布到https web服务。我是PHP新手,所以我正在努力边学边学。我已经能够通过soapUI将xml数据发布到web服务,但我无法通过PHP重新创建以进行处理。如果任何一位PHP SOAP专家能够向我解释我做错了什么,那将是一个很大的帮助。下面是我试图发布到web服务的代码片段 <?php $user = "xxxxxx"; $password = "xxxxx"; $url = "https://esws.energystar.gov/Dat

大家晚上好

我一直在努力将xml数据发布到https web服务。我是PHP新手,所以我正在努力边学边学。我已经能够通过soapUI将xml数据发布到web服务,但我无法通过PHP重新创建以进行处理。如果任何一位PHP SOAP专家能够向我解释我做错了什么,那将是一个很大的帮助。下面是我试图发布到web服务的代码片段

<?php
$user = "xxxxxx"; 
$password = "xxxxx"; 
$url = "https://esws.energystar.gov/DataServices/servlet/webservices?ver=1.1&wsdlxml";
$post_string = <<<EOT
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:roof="http://www.energystar.gov/schema/Roof_Products_2_x/" xmlns:core="http://www.energystar.gov/schema/core/">
 <soapenv:Header/>
 <soapenv:Body>
    <roof:Roof_Products_submission>
       <core:core_submission>
          <core:Authentication_UserName>xxxxx</core:Authentication_UserName>
          <core:Authentication_Password>xxxxxxx</core:Authentication_Password>
  <core:Certification_Body_EPA_Issued_Organization_Id>xxxxxxx</core:Certification_Body_EPA_Issued_Organization_Id>
          <core:Is_Test_Submission>Yes</core:Is_Test_Submission>
       </core:core_submission>
       <!--1 or more repetitions:-->
       <roof:Roof_Products>
          <core:core_product_data>
             <core:ENERGY_STAR_Manufacturing_Partner>QPX Active Partner</core:ENERGY_STAR_Manufacturing_Partner>
             <core:ENERGY_STAR_Manufacturing_Partner_s_EPA_issued_Organization_ID>xxxxxxxxx</core:ENERGY_STAR_Manufacturing_Partner_s_EPA_issued_Organization_ID>
             <core:Partner_Contact_Name_For_This_Model>xxxxxxx</core:Partner_Contact_Name_For_This_Model>
             <core:Type_of_Transaction>Initial Certification</core:Type_of_Transaction>
             <core:Reason_for_Transaction>Initial Certification: Model Meets ENERGY STAR Requirements</core:Reason_for_Transaction>
             <core:Date_of_Transaction_Type>2010-12-31</core:Date_of_Transaction_Type>
             <core:ENERGY_STAR_Model_Identifier>TestID2929</core:ENERGY_STAR_Model_Identifier>
             <core:Certification_ID>TestCertID123</core:Certification_ID>
             <core:Family_ID>TestFamID123</core:Family_ID>
             <core:Model_Name>Model_Name1234</core:Model_Name>
             <core:Model_Number>Model_Number33453</core:Model_Number>
             <core:Brand_Name>Brand_Name1</core:Brand_Name>
             <core:Tested_Model_Name>Tested_Model_Name1</core:Tested_Model_Name>
             <core:Tested_Model_Number>Tested_Model_Number1</core:Tested_Model_Number>
             <!--Zero or more repetitions:-->
             <core:Additional_Models_Represented_by_Family_Series_or_DOE_Basic>
                <core:Additional_Model_Name>test</core:Additional_Model_Name>
                <core:Additional_Model_Number>12345</core:Additional_Model_Number>
                <core:Additional_Identifying_Information>non</core:Additional_Identifying_Information>
             </core:Additional_Models_Represented_by_Family_Series_or_DOE_Basic>
             <core:Is_the_Partner_Listed_the_Original_Equipment_Manufacturer_OEM>Yes</core:Is_the_Partner_Listed_the_Original_Equipment_Manufacturer_OEM>
             <core:If_the_Partner_is_Not_the_Original_Equipment_Manufacturer_Who_is>?</core:If_the_Partner_is_Not_the_Original_Equipment_Manufacturer_Who_is>
             <core:Currently_Available_on_Market>Yes</core:Currently_Available_on_Market>
             <core:Date_Available_On_Market>2010-12-31</core:Date_Available_On_Market>
             <core:Date_Tested>2010-12-31</core:Date_Tested>
             <core:Date_CB_Notified_Partner_of_Model_Qualification>2010-12-31</core:Date_CB_Notified_Partner_of_Model_Qualification>
             <core:Certification_Body_Contact_Name_for_This_Model>QPX Certification Body 1</core:Certification_Body_Contact_Name_for_This_Model>
             <!--Zero or more repetitions:-->
             <core:Laboratory>
                <core:Laboratory_EPA_issued_Organization_ID>xxxxxxxxx</core:Laboratory_EPA_issued_Organization_ID>
                <core:Laboratory_Contact_for_This_Model>QPX Laboratory Test</core:Laboratory_Contact_for_This_Model>
             </core:Laboratory>
             <!--1 to 8 repetitions:-->
             <core:To_What_Major_Markets_is_This_Model_Sold>United States</core:To_What_Major_Markets_is_This_Model_Sold>
             <core:Notes>notes on the product</core:Notes>
          </core:core_product_data>
          <roof:ENERGY_STAR_Specification_Version>2.2</roof:ENERGY_STAR_Specification_Version>
          <roof:Product_Type>Single-Ply</roof:Product_Type>
          <roof:Measured_Initial_Solar_Reflectance>0.25</roof:Measured_Initial_Solar_Reflectance>
          <roof:Reported_Initial_Solar_Reflectance>0.26</roof:Reported_Initial_Solar_Reflectance>
          <roof:Initial_Solar_Reflectance_Test_Method>ASTM E903-96</roof:Initial_Solar_Reflectance_Test_Method>
          <roof:Measured_Solar_Reflectance_After_Three_Years>0.15</roof:Measured_Solar_Reflectance_After_Three_Years>
          <roof:Reported_Reflectance_After_Three_Years>0.16</roof:Reported_Reflectance_After_Three_Years>
          <roof:Solar_Reflectance_After_Three_Years_Test_Method>ASTM C1549-09</roof:Solar_Reflectance_After_Three_Years_Test_Method>
          <roof:Measured_Initial_Emissivity>0.01</roof:Measured_Initial_Emissivity>
          <roof:Reported_Initial_Emissivity>0.02</roof:Reported_Initial_Emissivity>
          <roof:Initial_Emissivity_Test_Method_Used>ASTM E408-71(1996) e1</roof:Initial_Emissivity_Test_Method_Used>
          <roof:Low_Slope>Yes</roof:Low_Slope>
          <roof:Steep_Slope>Yes</roof:Steep_Slope>
          <roof:Roof_Cleaned_Prior_to_Third_Year_Test>No</roof:Roof_Cleaned_Prior_to_Third_Year_Test>
          <roof:Warranty_Period>abcdefg</roof:Warranty_Period>
       </roof:Roof_Products>
    </roof:Roof_Products_submission>
 </soapenv:Body>
  </soapenv:Envelope>
 EOT;

  $soap_do = curl_init();  
  curl_setopt($soap_do, CURLOPT_URL,            $url );    
  curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);  
  curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);  
  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,    $post_string);  
  curl_setopt($soap_do, CURLOPT_HTTPHEADER,     array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($post_string) ));  
  curl_setopt($soap_do, CURLOPT_USERPWD, $user . ":" . $password); 
  $result = curl_exec($soap_do); 
  $err = curl_error($soap_do);   
  ?>


测试
12345
不
对
?
对
2010-12-31
2010-12-31
2010-12-31
QPX认证机构1
xxxxxxxxx
QPX实验室测试
美国
产品说明
2.2
单层
0.25
0.26
ASTM E903-96
0.15
0.16
ASTM C1549-09
0.01
0.02
ASTM E408-71(1996)e1
对
对
不
abcdefg
EOT;
$soap\u do=curl\u init();
curl_setopt($soap_do,CURLOPT_URL,$URL);
curl_setopt($soap_do,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($soap_do,CURLOPT_TIMEOUT,10);
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,$post_string);
curl_setopt($soap_do,CURLOPT_HTTPHEADER,array('Content-Type:text/xml;charset=utf-8','Content-Length:'.strlen($post_string));
curl_setopt($soap_do,CURLOPT_USERPWD,$user.:“$password);
$result=curl\u exec($soap\u do);
$err=curl\u error($soap\u do);
?>

非常感谢您的任何帮助。

我不确定这是否正确,但应该是以下几点:

$namespace = 'https://esws.energystar.gov';
$auth = new ChannelAdvisorAuth($user, $password); 
$header = new SoapHeader($namespace, 'APICredentials', $auth, false); 

$soap = new SoapClient($url);
$soap->__setSoapHeaders($header);
$soap->DataServices_Server($post_string);
我希望这将为您指明正确的方向:)