2013-03-06 6 views
0

Je travaille sur un projet où il est nécessaire de vérifier les membres inscrits avec National Student ClearingHouse en utilisant leur API. J'ai cherché partout sur Internet pour trouver un extrait qui décrit la méthode ou l'exemple comment interroger cela, mais pas de chance jusqu'à présent. La documentation est également très limitée à mettre en œuvre en php plus je n'ai jamais travaillé sur SOAP, ce qui rend cela encore plus compliqué pour moi.Mise en œuvre du service Web SOAP pour étudiants ClearingHouse

Lien vers Documentation: https://docs.google.com/file/d/1kZvEeobFNq3kbhZKJnagkVhcWhKHHwL5dwckbJLTB4dhNpMSF7cjAVOp9cne/edit?usp=sharing

D'une certaine façon, j'ai réussi à commencer voici le code:

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

qui sort:

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

esprit Collé très mal.

Répondre

0

L'erreur est déclarée comme suit: "l'objet n'a pas de propriété 'BackgroundSearchPackage'", fondamentalement votre appel de savon n'obéit pas aux exigences du wsdl. Je vais les coller ci-dessous. Cet appel particulier attend le contenu et les attributs du nœud. Voir le premier commentaire dans la documentation php ici pour voir comment cela se fait: http://php.net/manual/en/soapclient.soapcall.php

Donc, avec cela dit, vous pouvez essayer de faire votre appel avec vos données:

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

Note: avec du savon, tous disponibles opérations et les descriptions de leurs entrées, et les valeurs de retour sont décrits dans le wsdl. Vous avez fourni l'URL: https://xml.studentclearinghouse.org/ws/wsdl/HRXMLVerify.wsdl. Je suis coller ci-dessous les éléments d'information pertinents pour votre cas:

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

Description BackgroundCheck

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

Description BackgroundCheckType (se référer à la ligne 3195 de wsdl). BackgroundCheckType contient un élément "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

d'envoyer un 'BackgroundSearchPackage' avec un tableau rempli avec les données du membre pour lequel je demande la vérification. C'est pourquoi c'est obligatoire. –

+0

Bon, eh bien, vous devez obéir aux exigences du wsdl, et il n'y a pas de "BackgroundSearchPackage" au même niveau que "BackgroundCheck". Mais vous avez raison, j'ai répondu trop rapidement sans vérifier le wsdl dans les détails. "BackgroundSearchPackage" est défini * dans * "BackgroundCheck" et toutes les autres entrées (par exemple userid) sont des attributs. J'ai modifié ma réponse et ajouté des liens de référence et des extraits du wsdl. –

+0

argh, enregistré la réponse trop rapidement, édité une dernière fois, j'espère que cela fonctionne! Et une dernière remarque: lorsque vous avez imbriqué des types complexes comme ceux-ci, vous devriez considérer le mapping de classe, voir le paramètre classmap pour le constructeur SoapClient: http://www.php.net/manual/en/soapclient.soapclient.php –