如何使用php构建WSDL客户端,根据此xml

时间:2015-02-05 03:41:15

标签: php soap wsdl

我是WSDL的初学者,并且想知道如何使用php构建WSDL客户端。

的xml:

<s:element name="RegisterNewUser">
    <s:complexType>
        <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string"/>
            <s:element minOccurs="0" maxOccurs="1" name="userPlainPassword" type="s:string"/>
            <s:element minOccurs="0" maxOccurs="1" name="userPlainKey" type="s:string"/>
            <s:element minOccurs="0" maxOccurs="1" name="email" type="s:string"/>
            <s:element minOccurs="0" maxOccurs="1" name="userInfo" type="tns:UserInfo"/>
            <s:element minOccurs="1" maxOccurs="1" name="emailNotificationTopUp" type="s:boolean"/>
            <s:element minOccurs="1" maxOccurs="1" name="locationId" type="s:int"/>
            <s:element minOccurs="1" maxOccurs="1" name="referralId" type="s:int"/>
            <s:element minOccurs="1" maxOccurs="1" name="activationRequired" type="s:boolean"/>
            <s:element minOccurs="0" maxOccurs="1" name="SNSname" type="s:string"/>
            <s:element minOccurs="0" maxOccurs="1" name="SNSid" type="s:string"/>
        </s:sequence>
    </s:complexType>
</s:element>

<s:complexType name="IntReturnValue">
    <s:sequence>
        <s:element minOccurs="1" maxOccurs="1" name="value" type="s:int"/>
        <s:element minOccurs="0" maxOccurs="1" name="returnCode" type="s:string"/>
        <s:element minOccurs="0" maxOccurs="1" name="returnMessage" type="s:string"/>
    </s:sequence>
</s:complexType>

<s:element name="RegisterNewUserResponse">
    <s:complexType>
        <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="RegisterNewUserResult" type="tns:IntReturnValue"/>
        </s:sequence>
    </s:complexType>
</s:element>

myFunction的:

function registerToBilling($username, $password, $email, $displayname, $pin)
{
    $mySetting = MYSetting();
    $url = $mySetting['ws']['url']['userws'];
    $pass_ws = $mySetting['ws']['header']['pass'];
    $username_ws = $mySetting['ws']['header']['username'];  

    $client = new SoapClient($url, array("classmap" => array("userInfo" => "userInfo"),'soap_version'=>SOAP_1_2, "trace" => true, "exception" => 0,'cache_wsdl'=>WSDL_CACHE_NONE));
    $auth = new authentication_header($username_ws ,$pass_ws );
    $header = new SoapHeader('http://myApp.org/', 'AuthHeader', $auth, false);
    $client->__setSoapHeaders(array($header));

    $myObject = new userInfo();  
    $myObject->userId = 0; 
    $myObject->name =  $username;
    $myObject->nickName = $username;
    $myObject->ssno = 0; 
    $myObject->countryId = 1; 
    $myObject->gender = 1; // 0 female, 1 male
    $myObject->birthday = date("1987-08-07");  // yyyy-mm-dd
    $myObject->registerDate = date("1987-08-07"); // yyyy-mm-dd
    $myObject->lastUpdateDate = date("1987-08-07"); // yyyy-mm-dd
    $myObject->email = $email ; 
    $myObject->zipcode = 16431; 
    $myObject->addr =  "addr"; 
    $myObject->addrDetail = "addr detail"; 
    $myObject->phoneNumber = "123456789";
    $myObject->isSubscribe = 1; 
    $myObject->BBPin = "123456789";
    $myObject->mobileNumber = "123456789";

    $userName=$username;  
    $userPassword=$password;  
    $pin=$pin;  
    $emailNotificationTopUp=0;
    $locationId=0;  
    $referralId=0;  
    $activationRequired=0;  

    $paramsInfo = array('userName' => $userName, 'userPlainPassword' => $userPassword, 'userPlainKey' => $pin, 'email' => $email, 'userInfo' => $myObject, 'emailNotificationTopUp' => $emailNotificationTopUp, 'locationId' => $locationId, 'referralId' => $referralId, 'activationRequired' => $activationRequired  );

    $wallet = 0;
    try
    {
        $result2 = $client->__soapCall("RegisterNewUser", array('parameters'=> $paramsInfo), NULL, NULL);

        try
        {
            if($result2->RegisterNewUserResult->returnCode == "100")
            {
                return $result2->RegisterNewUserResult->returnCode;
            }
            else
            {
                return $result2->RegisterNewUserResult->returnCode;
            }
        }
        catch(exception $ex)
        {
            return $ex;
        }
    }
    catch (SoapFault $exception) 
    {

    }   
}

现在,我想知道如何在注册表单中使用功能,仅限字段用户名,电子邮件,密码和PIN

感谢

0 个答案:

没有答案