PHP5 SoapClient and Apache Axis interop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've got an Soap server running under Apache Axis (Java) 1.2RC3, using auto-generated wsdl. I'm trying to write the Soap client in PHP5 using the SoapClient class, but the two seem to have trouble talking.

At first, I used RPC encoded WSDL, but the SoapClient couldn't talk with it and after further reading, it seems this has been an interoperability nightmare and isn't supported at all by .NET (which must also be a client, but later on). So I changed my Axis server to use document/literal wrapped WSDL. And still the PHP client doesn't play nice.

Specifically, Axis is throwing an exception - java.lang.IncompatibleClassChangeError
This means that the incoming parameters don't match anything that can be translated to classes that Axis deals with... in this case, Strings from one namespace can't be converted into Strings from another. The WSDL from the service wants the parameters to be in the xmlns:xsd="http://www.w3.org/2001/XMLSchema"; namespace, while the SoapClient sends them in the xmlns:ns1="http://rpc.whisper.ucsc.edu"; namespace. I've tried using the SoapVar class to specify the XMLSchema namespace, but that failed (see below).


The project I'm working on is going to be pretty big... so for me to not have autogenerated WSDL and client requests will make the entire thing a massive headache. Does anyone have ideas for making SoapClient and Axis play nice together? Maybe a different PHP-based client mechanism, or some way to force the SoapClient to use a specific namespace on parameters?

Thanks for any help!

Mark


The WSDL looks like this (formatted a little for readability):

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
targetNamespace="https://localhost:8043/whisper-server/ws/UserService";
xmlns:apachesoap="http://xml.apache.org/xml-soap";
xmlns:impl="https://localhost:8043/whisper-server/ws/UserService";
xmlns:intf="https://localhost:8043/whisper-server/ws/UserService";
xmlns:tns1="http://rpc.whisper.ucsc.edu";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<!--WSDL created by Apache Axis version: 1.2RC3
Built on Feb 28, 2005 (10:15:14 EST)-->
<wsdl:types>
<schema elementFormDefault="qualified"
targetNamespace="http://rpc.whisper.ucsc.edu";
xmlns="http://www.w3.org/2001/XMLSchema";>


   <element name="confirmCredentials">
    <complexType>
     <sequence>
      <element name="username" type="xsd:string"/>
      <element name="password" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>

   <element name="confirmCredentialsResponse">
    <complexType>
     <sequence>
      <element name="confirmCredentialsReturn" type="xsd:boolean"/>
     </sequence>
    </complexType>
   </element>

   <element name="changePassword">
    <complexType>
     <sequence>
      <element name="username" type="xsd:string"/>
      <element name="password" type="xsd:string"/>
      <element name="newPassword" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>

   <element name="changePasswordResponse">
    <complexType>
     <sequence>
      <element name="changePasswordReturn" type="xsd:boolean"/>
     </sequence>
    </complexType>
   </element>
  </schema>
 </wsdl:types>

   <wsdl:message name="confirmCredentialsRequest">
      <wsdl:part element="tns1:confirmCredentials" name="parameters"/>
   </wsdl:message>

   <wsdl:message name="changePasswordRequest">
      <wsdl:part element="tns1:changePassword" name="parameters"/>
   </wsdl:message>

<wsdl:message name="confirmCredentialsResponse">
<wsdl:part element="tns1:confirmCredentialsResponse" name="parameters"/>
</wsdl:message>


<wsdl:message name="changePasswordResponse">
<wsdl:part element="tns1:changePasswordResponse" name="parameters"/>
</wsdl:message>


<wsdl:portType name="JaxRpcUserService">
<wsdl:operation name="confirmCredentials">
<wsdl:input message="impl:confirmCredentialsRequest" name="confirmCredentialsRequest"/>
<wsdl:output message="impl:confirmCredentialsResponse" name="confirmCredentialsResponse"/>
</wsdl:operation>


<wsdl:operation name="changePassword">
<wsdl:input message="impl:changePasswordRequest" name="changePasswordRequest"/>
<wsdl:output message="impl:changePasswordResponse" name="changePasswordResponse"/>
</wsdl:operation>
</wsdl:portType>


<wsdl:binding name="UserServiceSoapBinding" type="impl:JaxRpcUserService">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="confirmCredentials">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="confirmCredentialsRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="confirmCredentialsResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>


      <wsdl:operation name="changePassword">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="changePasswordRequest">
            <wsdlsoap:body use="literal"/>
         </wsdl:input>
         <wsdl:output name="changePasswordResponse">
            <wsdlsoap:body use="literal"/>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>

<wsdl:service name="JaxRpcUserServiceService">
<wsdl:port binding="impl:UserServiceSoapBinding" name="UserService">
<wsdlsoap:address location="https://localhost:8043/whisper-server/ws/UserService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


===================================================

Using the SoapClient, I've done this:

$msgParams = array(
            'username' => $this->username,
            'password' => $this->password );
$result = $userService->confirmCredentials( (object) $msgParams );

which generates this request:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
    xmlns:ns1="http://rpc.whisper.ucsc.edu";>
<SOAP-ENV:Body>
<ns1:confirmCredentials>
    <ns1:username>123</ns1:username>
    <ns1:password>poi</ns1:password>
</ns1:confirmCredentials>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

===================================================

After reading some of the messages on the newsgroup, I also tried this:

$msgParams = array(
            'username' => $this->username,
            'password' => $this->password );
$soapParams = new SoapVar( (object) $msgParams, SOAP_ENC_OBJECT,
            "confirmCredentials", "http://www.w3.org/2001/XMLSchema"; );
$result = $userService->confirmCredentials( $soapParams );

And that got me this request:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
    xmlns:ns1="http://rpc.whisper.ucsc.edu";>
<SOAP-ENV:Body>
<ns1:confirmCredentials>
    <username>123</username>
    <password>poi</password>
</ns1:confirmCredentials>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>





As far as I can tell, the big difference is the specification of a namespace before each field in the first request and no namespace before fields in the second... though my understanding of XML namespaces is limited, given the namespace on the enclosing item ns1:confirmCredentials, that namespace is also applied to the child items, meaning that both requests are essentially the same.

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux