2013-03-06 3 views
0

저는 API를 사용하여 등록 된 회원을 National Student ClearingHouse와 확인해야하는 프로젝트를 진행하고 있습니다. 나는 방법이나 예제를 설명하는 방법을 설명하는 일부 스 니펫을 찾기 위해 인터넷에서 사방을 조사 해왔다. 그러나 지금까지는 행운이 없다. 문서도 php에서 구현하기 위해 매우 제한되어 있습니다. 나는 SOAP에 대해 한 번도 다뤄 본 적이 없기 때문에이 작업을 더욱 복잡하게 만듭니다. 문서에National Student ClearingHouse SOAP 웹 서비스 구현

링크 :

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

스턱 재치를 어떻게 든 https://docs.google.com/file/d/1kZvEeobFNq3kbhZKJnagkVhcWhKHHwL5dwckbJLTB4dhNpMSF7cjAVOp9cne/edit?usp=sharing

내가 여기 시작하는 것을 처리 한 코드이다 이것은 매우 나쁘다.

답변

0

"개체에 'BackgroundSearchPackage'속성이 없습니다. 기본적으로 SOAP 호출은 wsdl의 요구 사항을 따르지 않습니다. 아래에 붙여 넣습니다. 이 특정 호출은 노드 내용과 속성 모두를 필요로합니다. 즉 어떻게하는지 보려면 여기를 PHP는 문서의 첫 번째 주석을 참조하십시오 : http://php.net/manual/en/soapclient.soapcall.php

을 그렇게 말 그래서, 당신은 귀하의 데이터와 통화를 시도 할 수 :

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

참고 : 비누와 함께 사용 가능한 모든를 입력 및 반환 값에 대한 작업 및 설명은 wsdl에 설명되어 있습니다. 당신은 URL을 제공했습니다 : https://xml.studentclearinghouse.org/ws/wsdl/HRXMLVerify.wsdl. 나는 당신의 사건에 대한 정보의 관련 부분 아래에 붙여 오전 : 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> 

BackgroundCheck

<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> 

설명 (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'를 보내야합니다. 그것이 의무적 인 이유입니다. –

+0

맞습니다. wsdl의 요구 사항을 준수해야하며 "BackgroundCheck"와 동일한 수준의 "BackgroundSearchPackage"가 없습니다. 하지만 당신 말이 맞아요, 나는 wsdl을 자세히 검사하지 않고 너무 빨리 대답했다. "BackgroundSearchPackage"는 * "BackgroundCheck"에 정의되어 있으며 다른 모든 입력 (예 : userid)은 속성입니다. 내 대답을 수정하고 wsdl에서 일부 참조 링크 및 스 니펫을 추가했습니다. –

+0

아아, 너무 빨리 답변을 저장하고 마지막으로 편집 한 항목, 제대로 작동하기를 바랍니다. 마지막으로 다음과 같은 복잡한 유형을 중첩하면 클래스 매핑을 고려해야합니다. SoapClient 생성자의 클래스 맵 매개 변수를 참조하십시오. http://www.php.net/manual/en/soapclient.soapclient.php –