创建php SOAP请求

时间:2014-10-15 16:07:35

标签: php soap soap-client

我想创建肥皂请求,如下所示

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/10.0">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:updateUser sequence="?">
         <!--You have a CHOICE of the next 2 items at this level-->
         <uuid>{74932749237942794729473927493829}</uuid>
         <userid>?</userid>
         <associatedGroups>
            <!--Zero or more repetitions:-->
            <userGroup>
               <name>Standard CTI Enabled</name>
               <!--Optional:-->
               <userRoles>
                  <!--Zero or more repetitions:-->
                  <userRole>Standard CTI Enabled</userRole>
               </userRoles>
            </userGroup>
            <userGroup>
               <name>Standard CCM End Users</name>
               <!--Optional:-->
               <userRoles>
                  <!--Zero or more repetitions:-->
                  <userRole>Standard CCM End Users</userRole>
               </userRoles>
            </userGroup>
         </associatedGroups>
      </ns:updateUser>
   </soapenv:Body>
</soapenv:Envelope>

到目前为止,我已将此作为我的代码:

$userId = "example@mydomain.com";
$retAccessWebex["UserUuid"] = "{74932749237942794729473927493829}";            //sample userUuid
    $userGroup = array();
    $userRoleCTI = array("Standard CTI Enabled");
    $userGroup[] = array(
        "name" => "Standard CTI Enabled",
        "userRoles" => array(
            "userRole" => $userRoleCTI,
        )
    );
    $userRoleCCM = array("Standard CCM End Users");
    $userGroup[] = array(
        "name" => "Standard CCM End Users",
        "userRoles" => array(
            "userRole" => $userRoleCCM,
        )
    );

    $param = array(
        "uuid" => $retAccessWebex["UserUuid"],
        "userid" => $userId,
        "associatedGroups" => array(
            array(
                "userGroup" => $userGroup,
            )
        )
    );
    $mywsdl = "pathToSchemaWsdl/AXLAPI.wsdl";
    $wsdl = "https://127.0.0.1:8443/axl/";
    $client = new SoapClient($mywsdl,
        array('trace' => true,
            'exceptions' => true,
            'location' => $wsdl,
            'login' => 'administrator',
            'password' => 'mtp455w0rd',
        ));
    $response = $client->updateUser($param);

然而,在执行时,我收到此错误消息:

  

致命错误:未捕获的SoapFault异常:[发件人] SOAP-ERROR:   编码:对象没有'name'属性

1 个答案:

答案 0 :(得分:0)

尝试查看请求中的内容

echo $ client-&gt; __ getLastRequestHeaders(); echo $ client-&gt; __ getLastRequest();