2013-03-06 22 views
0

我正在開發一個項目,要求使用他們的API在National Student ClearingHouse中驗證註冊成員。我一直在尋找互聯網上的任何地方,以找到一些片段,描述方法或示例如何查詢,但迄今爲止沒有運氣。文檔在php plus中的實現也非常有限我從來沒有使用過SOAP,所以這對我來說更加複雜。國家學生ClearingHouse SOAP web服務實現

鏈接到文檔: https://docs.google.com/file/d/1kZvEeobFNq3kbhZKJnagkVhcWhKHHwL5dwckbJLTB4dhNpMSF7cjAVOp9cne/edit?usp=sharing

不知怎的,我設法這裏介紹的是代碼:

$soap_url = 'https://xml.studentclearinghouse.org/ws/wsdl/HRXMLVerify.wsdl'; 

$client = new SoapClient($soap_url, array(
      'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', 
      'SOAPENC' => 'http://schemas.xmlsoap.org/soap/encoding/', 
      'xsi'  => 'http://www.w3.org/2001/XMLSchemainstance', 
      'xsd'  => 'http://www.w3.org/2001/XMLSchema' 
    )); 

$data = array(
     'BackgroundCheck' => array(
       'account' => 'xxxx', 
       'userid' => 'xxxxx', 
       'password' => 'xxxxx' 
      ), 

     'BackgroundSearchPackage' => array() 

    ); 
echo '<pre>'; 
print_r($client->__soapCall('verifyHRXML', $data)); 

,輸出:

SoapFault Object 
(
    [message:protected] => SOAP-ERROR: Encoding: object has no 'BackgroundSearchPackage' property 
    [string:Exception:private] => 
    [code:protected] => 0 
    [file:protected] => /Applications/MAMP/htdocs/nch/index.php 
    [line:protected] => 39 
    [trace:Exception:private] => Array 
     (
      [0] => Array 
       (
        [file] => /Applications/MAMP/htdocs/nch/index.php 
        [line] => 39 
        [function] => __soapCall 
        [class] => SoapClient 
        [type] => -> 
        [args] => Array 
         (
          [0] => verifyHRXML 
          [1] => Array 
           (
            [BackgroundCheck] => Array 
             (
              [account] => xxxxxx 
              [userid] => xxxxx 
              [password] => xxxxxx 
             ) 

            [BackgroundSearchPackage] => Array 
             (
             ) 

           ) 

         ) 

       ) 

     ) 

    [previous:Exception:private] => 
    [faultstring] => SOAP-ERROR: Encoding: object has no 'BackgroundSearchPackage' property 
    [faultcode] => Client 
    [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ 
) 

卡住機智這非常糟糕。

回答

0

錯誤的規定爲:「對象沒有'BackgroundSearchPackage'屬性」,基本上你的soap調用不符合wsdl的要求。我會在下面粘貼這些。這個特定的調用期望BOTH節點的內容和屬性。請參見PHP文檔在這裏的第一個評論,看看這樣做了:http://php.net/manual/en/soapclient.soapcall.php

因此,既然說了,你可以嘗試讓你的電話與您的數據爲:

$data = array(
    'BackgroundCheck' => array(
      '_' => array(
       'BackgroundSearchPackage' => array() 
       ), 
      'account' => 'xxxx', 
      'userid' => 'xxxxx', 
      'password' => 'xxxxx' 
     ) 
); 

注:用肥皂,所有可用其輸入的操作和描述以及返回值在wsdl中進行了描述。您提供了網址:https://xml.studentclearinghouse.org/ws/wsdl/HRXMLVerify.wsdl。我粘貼下面的相關條信息爲您的情況:

<message name="HRXMLVerifySoapIn"> 
    <part name="parameters" element="s0:BackgroundCheck"/> 
</message> 
<message name="HRXMLVerifySoapOut"> 
    <part name="parameters" element="s0:BackgroundReports"/> 
</message> 
<portType name="HRXMLVerifySoapPort"> 
    <operation name="verifyHRXML"> 
     <documentation>Display the detail results of verification.</documentation> 
     <input message="intf:HRXMLVerifySoapIn"/> 
     <output message="intf:HRXMLVerifySoapOut"/> 
    </operation> 
</portType> 

背景調查

BackgroundCheckType說明的
<xsd:element name="BackgroundCheck" type="BackgroundCheckType" > 
    <xsd:annotation> 
    <xsd:documentation>Parent Element for specifying Search Subject specfic data for Standalone Searches.</xsd:documentation> 
    </xsd:annotation> 
</xsd:element> 

說明(參見WSDL行3195)。 BackgroundCheckType 包含元素「BackgroundSearchPackage」。

<xsd:complexType name="BackgroundCheckType" > 
    <xsd:sequence> 
     <xsd:element name="ReferenceId" type="EntityIdType" minOccurs="0"> 
      <xsd:annotation> 
       <xsd:documentation>Reference Number associated with all searches within the XML Document.</xsd:documentation> 
      </xsd:annotation> 
     </xsd:element> 
     <xsd:element name="BackgroundSearchPackage" maxOccurs="unbounded"> 
      <xsd:annotation> 
       <xsd:documentation>Root element containing all screening related information for a single Search Subject.</xsd:documentation> 
      </xsd:annotation> 
      <xsd:complexType> 
       <xsd:sequence> 
        <xsd:sequence> 
         <xsd:element name="ReferenceId" type="EntityIdType" minOccurs="0"> 
          <xsd:annotation> 
           <xsd:documentation>Reference Number associated with all searches within the specified package.</xsd:documentation> 
          </xsd:annotation> 
         </xsd:element> 
         <xsd:element name="ClientContact" type="ReferralType" minOccurs="0"> 
          <xsd:annotation> 
           <xsd:documentation>Contact point within clients organization regarding details of screening package.< /xsd:documentation> 
          </xsd:annotation> 
         </xsd:element> 
         <xsd:element name="Organization" type="ReferralType" minOccurs="0" maxOccurs="unbounded"> 
          <xsd:annotation> 
           <xsd:documentation>Identifies the organization that the search(s) will be performed upon or on behalf of depending on the value of type.</xsd:documentation> 
          </xsd:annotation> 
         </xsd:element> 
         <xsd:element name="PersonalData" type="ScreeningPersonalDataType" minOccurs="0" maxOccurs="unbounded"> 
          <xsd:annotation> 
           <xsd:documentation>Personal data related to the Search Subject that the search(s) will be performed upon.</xsd:documentation> 
          </xsd:annotation> 
         </xsd:element> 
         <xsd:element name="Screenings" type="ScreeningRequestType" minOccurs="0" maxOccurs="unbounded"></xsd:element> 
        </xsd:sequence> 
       </xsd:sequence> 
       <xsd:attribute name="type" type="xsd:string" use="optional"></xsd:attribute> 
       <xsd:attribute name="action" type="xsd:string" use="optional"></xsd:attribute> 
      </xsd:complexType> 
     </xsd:element> 
     <xsd:element ref="UserArea" minOccurs="0"></xsd:element> 
    </xsd:sequence> 
    <xsd:attribute name="userId" type="xsd:string" use="required"> 
     <xsd:annotation> 
      <xsd:documentation>Client identification. This will be provided to the client by the organization performing the screenings.</xsd:documentation> 
     </xsd:annotation> 
    </xsd:attribute> 
    <xsd:attribute name="password" type="xsd:string" use="optional"></xsd:attribute> 
    <xsd:attribute name="account" type="xsd:string" use="optional"></xsd:attribute> 
    <xsd:attribute name="location" type="xsd:string" use="optional"></xsd:attribute> 
    <xsd:attribute name="version" type="xsd:string" use="optional" default="2_0"></xsd:attribute> 
    <xsd:attribute ref="xml:lang" use="optional"></xsd:attribute> 
</xsd:complexType> 
+0

必須發送'BackgroundSearchPackage'與一個數組填充我請求驗證的成員的數據。這就是強制性的原因。 – 2013-03-06 15:04:48

+0

好吧,你需要遵守wsdl的要求,並且沒有「BackgroundSearchPackage」與「BackgroundCheck」相同。但是你是對的,我沒有詳細檢查wsdl就回答太快了。 「BackgroundSearchPackage」被定義在*「BackgroundCheck」中,並且所有其他輸入(例如用戶ID)都是屬性。我修改了我的答案,並添加了一些來自wsdl的參考鏈接和片段。 – 2013-03-06 15:42:18

+0

ARGH,回答得太快,最後一次編輯,我希望它的作品!還有最後一個注意事項:當你嵌套像這樣的複雜類型時,應該考慮類映射,請參閱SoapClient構造函數的classmap參數:http://www.php.net/manual/en/soapclient.soapclient.php – 2013-03-06 15:44:58