0

我正在开展一个项目,该项目需要使用他们的 API 向 National Student ClearingHouse 验证注册成员。我一直在互联网上到处寻找一些描述如何查询方法或示例的片段,但到目前为止还没有运气。文档在 php 中实现也非常有限,而且我从未在 SOAP 上工作过,所以这对我来说更加复杂。

文档链接: 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/
)

非常糟糕地卡住了这一点。

4

1 回答 1

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

注意:使用soap,所有可用的操作及其输入和返回值的描述都在wsdl.xml 中描述。您提供了网址: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>

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>

BackgroundCheckType 的描述(参考 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>
于 2013-03-06T14:55:19.787 回答