0

我有以下客户端代码:

 $user = new SoapVar(array (
            "account-id" => 5,
            'first-name' => "Colby",
            'last-name' => "Meier",
            'email' => "colbymeier1337@gmail.com",
            'passwd' => "password",
            'user-type' => 2,
            'phone' => "555-555-1234",
            'mobile' => "555-555-1234",
            'website' => "http://www.notarealwebsite.com"
    ), XSD_ANYTYPE, "ns:CreateUserType", "http://192.168.1.120/Client_Billing.wsdl");

 $createUser = array (
        "session-id" => "testsession",
        "user" => $user
    );


 try {
    $test = $client->CreateUser(array("parameters"=>$createUser));
 } catch(Exception $ex) { //Request failed, print out why
    echo "<pre>Error:\n\t".$ex->getMessage()."\n</pre>";
 }

不幸的是,我知道我做错了什么都是愚蠢的简单的事情,但对于我的生活,我无法找到它(对 Soap 来说非常新)。

我得到的错误信息是:

[Wed Jan 23 13:59:04 2013] [error] [client 192.168.1.141] PHP Fatal error:  SOAP-ERROR: Encoding: object has no 'session-id' property in /var/www/test_soap/client_avid_new.php on line 107, referer: http://192.168.1.120/test_soap/

相关 WSDL 信息:

<element name="CreateUser">
    <complexType>
        <sequence>
            <element name="session-id" type="xsd:string" minOccurs="1" maxOccurs="1"/>
            <element name="user" type="ns:CreateUserType" minOccurs="1" maxOccurs="1"/>
        </sequence>
    </complexType>
</element>
<complexType name="CreateUserType">
    <sequence>
        <element name="account-id" type="xsd:int" minOccurs="1" maxOccurs="1"/>
        <element name="first-name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
        <element name="last-name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
        <element name="email" type="xsd:string" minOccurs="1" maxOccurs="1"/>
        <element name="passwd" type="xsd:string" minOccurs="1" maxOccurs="1"/>
        <element name="user-type" type="xsd:int" minOccurs="1" maxOccurs="1"/>
        <element name="phone" type="xsd:string" minOccurs="1" maxOccurs="1"/>
        <element name="mobile" type="xsd:string" minOccurs="1" maxOccurs="1"/>
        <element name="website" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    </sequence>
</complexType>

相关服务器代码:

class Client_Billing extends SoapClient {
    function __call ($function_name , $arguments) {
        $response = parent::__call ($function_name , $arguments);
        $this->httpsocket = NULL;
        return $response;
    }
    /**
     * Default class map for wsdl=>php
     * @access private
     * @var array
     */
    private static $classmap = array(
        "Results" => "Results",
        "CreatePlanType" => "CreatePlanType",
        "CreateUserType" => "CreateUserType",
        "UserType" => "UserType",
        "CreateAccountAddressType" => "CreateAccountAddressType",
        "AccountAddressType" => "AccountAddressType",
        "CreateResellerType" => "CreateResellerType",
        "CreateMarketingCenterType" => "CreateMarketingCenterType",
        "CCInfo" => "CCInfo",
        "FullAccountType" => "FullAccountType",
        "DateFormat" => "DateFormat",
        "Permissions" => "Permissions",
        "AuthedUser" => "AuthedUser",
        "StyleSheetRule" => "StyleSheetRule",
        "StyleSheet" => "StyleSheet",
        "CreatePermissionProfileType" => "CreatePermissionProfileType",
        "CreatePlan" => "CreatePlan",
        "CreatePlanResponse" => "CreatePlanResponse",
        "CreateUser" => "CreateUser",
        "CreateUserResult" => "CreateUserResult",
        "SaveUser" => "SaveUser",
        "SaveUserResult" => "SaveUserResult",
        "DeleteUser" => "DeleteUser",
        "DeleteUserResult" => "DeleteUserResult",
        "SuspendUser" => "SuspendUser",
        "SuspendUserResult" => "SuspendUserResult",
        "ActivateUser" => "ActivateUser",
        "ActivateUserResult" => "ActivateUserResult",
        "GetUsersForAccount" => "GetUsersForAccount",
        "GetUsersForAccountResult" => "GetUsersForAccountResult",
        "CreateAccountAddress" => "CreateAccountAddress",
        "CreateAccountAddressResponse" => "CreateAccountAddressResponse",
        "SaveAccountAddress" => "SaveAccountAddress",
        "SaveAccountAddressResponse" => "SaveAccountAddressResponse",
        "DeleteAccountAddress" => "DeleteAccountAddress",
        "DeleteAccountAddressResponse" => "DeleteAccountAddressResponse",
        "GetAddressesForAccount" => "GetAddressesForAccount",
        "GetAddressesForAccountResponse" => "GetAddressesForAccountResponse",
        "CreateReseller" => "CreateReseller",
        "CreateResellerResult" => "CreateResellerResult",
        "CreateMarketingCenter" => "CreateMarketingCenter",
        "CreateMarketingCenterResult" => "CreateMarketingCenterResult",
        "DeleteAccount" => "DeleteAccount",
        "DeleteAccountResult" => "DeleteAccountResult",
        "SuspendAccount" => "SuspendAccount",
        "SuspendAccountResult" => "SuspendAccountResult",
        "GetFullAccountDetails" => "GetFullAccountDetails",
        "GetFullAccountDetailsResult" => "GetFullAccountDetailsResult",
        "AuthUser" => "AuthUser",
        "AuthUserResult" => "AuthUserResult",
        "getNumberOfSignups" => "getNumberOfSignups",
        "getNumberOfSignupsResponse" => "getNumberOfSignupsResponse",
        "getNumberOfSignupsPerPlan" => "getNumberOfSignupsPerPlan",
        "getNumberOfSignupsPerPlanResponse" => "getNumberOfSignupsPerPlanResponse",
        "getRevenueByDateRange" => "getRevenueByDateRange",
        "getRevenueByDateRangeResponse" => "getRevenueByDateRangeResponse",
        "getRevenueByDateRangePerPlan" => "getRevenueByDateRangePerPlan",
        "getRevenueByDateRangePerPlanResponse" => "getRevenueByDateRangePerPlanResponse",
        "StoreStyleSheet" => "StoreStyleSheet",
        "StoreStyleSheetResult" => "StoreStyleSheetResult",
        "GetStyleSheet" => "GetStyleSheet",
        "GetStyleSheetResult" => "GetStyleSheetResult",
        "CreatePermissionProfile" => "CreatePermissionProfile",
        "CreatePermissionProfileResult" => "CreatePermissionProfileResult",
    );

    /**
     * Constructor using wsdl location and options array
     * @param string $wsdl WSDL location for this service
     * @param array $options Options for the SoapClient
     */
    public function __construct($wsdl="http://192.168.1.120/Client_Billing.wsdl", $options=array()) {
        foreach(self::$classmap as $wsdlClassName => $phpClassName) {
            if(!isset($options['classmap'][$wsdlClassName])) {
                $options['classmap'][$wsdlClassName] = $phpClassName;
            }
        }
        parent::__construct($wsdl, $options);
    }

    /**
     * Checks if an argument list matches against a valid argument type list
     * @param array $arguments The argument list to check
     * @param array $validParameters A list of valid argument types
     * @return boolean true if arguments match against validParameters
     * @throws Exception invalid function signature message
     */
    public function _checkArguments($arguments, $validParameters) {
        $variables = "";
        foreach ($arguments as $arg) {
            $type = gettype($arg);
            if ($type == "object") {
                $type = get_class($arg);
            }
            $variables .= "(".$type.")";
        }
        if (!in_array($variables, $validParameters)) {
            throw new Exception("Invalid parameter types: ".str_replace(")(", ", ", $variables));
        }
        return true;
    }


    /**
     * Service Call: CreateUser
     * Parameter options:
     * (CreateUser) parameters
     * @param mixed,... See function description for parameter options
     * @return CreateUserResult
     * @throws Exception invalid function signature message
     */
    public function CreateUser($mixed = null) {
        $validParameters = array(
            "(CreateUserType)",
        );
        $args = func_get_args();
        $this->_checkArguments($args, $validParameters);
        return $this->__call("CreateUser", $args);
    }

}}

$server = new SoapServer("http://192.168.1.120/Client_Billing.wsdl");
$server->setClass("Client_Billing");
$server->handle();
4

1 回答 1

0

所以我通过消除自己的白痴并发送

$test = $client->CreateUser($createUser);

但现在我回到这里发现的问题

于 2013-01-23T20:31:24.717 回答