如何在php中使用soapclient在wsdl中传递带扩展名base的complexType对象?

时间:2016-02-09 06:39:17

标签: php wsdl soap-client complextype

<s:complexType name="GuestMembershipInfo">
<s:complexContent mixed="false">
<s:extension base="tns:MembershipInfo">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SubGuests" type="tns:ArrayOfGuestMembershipInfo"/>
<s:element minOccurs="0" maxOccurs="1" name="GuestBillingInfo" type="tns:GuestBillingInfo"/>
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>


<s:element name="SaveMemberInfo">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="memInfo" type="tns:MembershipInfo"/>
<s:element minOccurs="1" maxOccurs="1" name="verifyZipCode" type="s:boolean"/>
</s:sequence>
</s:complexType>
</s:element>

这是我的.net代码,带有c#并且工作正常

         apiSvc = new net.csi.api.ApiService();
         GuestMembershipInfo m = new GuestMembershipInfo();

         m.Name = "Testing";
         m.EmailAddress = "test123@gmail.com";

         var rInfo = apiSvc.SaveMemberInfo(m, false);`

 This is my php function to saveMemberInfo and get this error
"Unable to cast object of type 'CSI.API.MembershipInfo' to type 'CSI.API.GuestMembershipInfo'."

    `public function SaveMemberInfo() {
            global $_sogh_soapUrl, $wcargs;
            $response = null;
            $memberInfo = array(
            'Name'=>"Test",
            'EmailAddress'=>'test123@gmail',
            );
            $args =  Array (
                'memInfo' => $memberInfo,
                'verifyZipCode'=>false,

        );
            try {
                $authResponse = $this->Authenticate (); // Here authonticate successfully

                if ($authResponse) {

                    $result = $this->wcfClient->SaveMemberInfo($args );
                    $result = $result->SaveMemberInfoResult;
                    if (isset ( $result->IsException ) && $result->IsException) {
                        $this->error ( 'Error: ' . print_r ( $result->Exception, true ) );
                    }else {
                        $response = $result->Value;
                    }
                }
            } catch ( SoapFault $fault ) {
                $this->error ( 'Fault: ' . $fault->faultcode . ' - ' . $fault->faultstring );
            } catch ( Exception $e ) {
                $this->error ( 'Error: ' . $e->getMessage () );
            }

            return $response;
        }

0 个答案:

没有答案