1

こんばんは、

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);   
  ?>

ありとあらゆる助けをいただければ幸いです

4

1 に答える 1

0

これが正しいかどうかはわかりませんが、次のようなものである必要があります。

$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);

これがあなたを正しい方向に向けることを願っています:)

于 2012-08-15T23:02:04.063 に答える