More SOAP questions. Also, SOAP bug? Or just me? (long)

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

 



* I'm not sure if this is a bug (unlikely) or if it's just me (highly
likely).  Given the following WSDL,

<?xml version="1.0"?>
<definitions xmlns:tns="urn:/test/testing"
xmlns:types="urn:/test/testing/types"
xmlns:sectypes="urn:/test/testing/soap/security/types"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/";
xmlns="http://schemas.xmlsoap.org/wsdl/"; name="TestTesting"
targetNamespace="urn:/test/testing">
  <types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns="urn:/test/testing/soap/security/types"
elementFormDefault="qualified"
targetNamespace="urn:/test/testing/soap/security/types">
      <xs:element name="authentication">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="username" minOccurs="1" maxOccurs="1"
type="xs:string"/>
            <xs:element name="password" minOccurs="1" maxOccurs="1"
type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns="urn:/test/testing/types" elementFormDefault="qualified"
targetNamespace="urn:/test/testing/types">
      <xs:import namespace="urn:/test/testing/soap/security/types"/>
      <xs:element name="ServerOperationInputObject">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="sectypes:authentication" minOccurs="0"
maxOccurs="1"/>
            <xs:element name="stringvar1" minOccurs="1" maxOccurs="1"
type="xs:NMTOKEN"/>
            <xs:element name="stringvar2" minOccurs="0" maxOccurs="1"/>
            <xs:element name="data-array" minOccurs="1" maxOccurs="1">
              <xs:complexType>
                <xs:sequence>
                  <xs:any maxOccurs="unbounded"/>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
  </types>
  <message name="ServerOperation">
    <part name="parameters" element="types:ServerOperationInputObject"/>
  </message>
  <message name="ServerOperationResponse">
    <part name="parameters" element="types:ServerOperationInputObjectResponse"/>
  </message>
  <portType name="TestTestingPort">
    <operation name="ServerOperation">
      <input message="tns:ServerOperationInputObject"/>
      <output message="tns:ServerOperationInputObjectResponse"/>
    </operation>
  </portType>
  <binding name="TestTestingBinding" type="tns:TestTestingPort">
    <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="ServerOperation">
      <soap:operation soapAction="server-operation"/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="TestTestingService">
    <documentation/>
    <port name="TestTestingPort" binding="tns:TestTestingBinding">
      <soap:address location="http://www.testserver.com"/>
    </port>
  </service>
</definitions>

I have the following code for calling the "ServerOperation" operation:

$oClient = new SoapClient( $sWSDL_URI,
                                        array( 'trace' => TRUE,
                                                 'exceptions'  => FALSE ));

$aParameters = array( 'authentication'  => array( 'username' => 'user',

'password' => 'pass' ),
                                  'stringvar1'      => 'here',
                                  'stringvar2'      => 'there',
                                  'data-array'      =>
'<sub-data>Bob</sub-data>' );

$oClient->ServerOperation( $aParameters );

But running that gives me a soap fault.  Apparently the "data-array"
node isn't populated in the SOAP message body.  I actually get a
different soap fault if I try to use classmap, but that is part of a
different question asked below.  So I then add in:

echo 'Types: <pre>' . print_r( $oClient->__getTypes(), TRUE ) . '</pre>';

and it turns out that the "data-array" definition in the WSDL is
getting translated as the following structure:

[XX] => struct data-array {
  any;
}

Umm, huh?  What's going on there?  Why is the SoapClient the part of
the namespace included in the definition for the type in the WSDL
(<xs:any maxOccurs="unbounded"/>) and turning the "any" into an
attribute of the structure?  So in order to get the "data-array" node
in the SOAP message body, I have to change the parameters definition
to:

$aParameters = array( 'authentication'  => array( 'username' => 'user',

'password' => 'pass' ),
                                  'stringvar1'      => 'here',
                                  'stringvar2'      => 'there',
                                  'data-array'      => array( 'any' =>
'<sub-data>Bob</sub-data>' ));

That seems exceptionally silly to me.  Is this a bug in the
SoapClient's translation of the WSDL?  A problem with the WSDL?  Or a
problem with my (albeit simplistic) code and is something I can and
should get around using proper attributes?  If it's the latter, how
can I define attributes for the various nodes?

* Now, this question is sort of an extension of the issue above.  If
instead of passing in an array, I use the classmap option for the
SoapClient, I get a different soap fault but it's based on the same
problem.  If instead my code looks like this:

$oClient = new SoapClient( $sWSDL_URI,
                                        array( 'trace'       => TRUE,
                                                 'exceptions'  => FALSE,
                                                 'classmap'    =>
array( 'ServerOperation' => 'MyClass' )));

and populate public properties of an instance of MyClass with the
appropriate values, the fault message I get then is instead "Encoding:
object hasn't 'any' property".  By setting the "data-array" property
(using variable gymnastics because PHP doesn't like dashes in variable
names) as an array with an "any" key, just as I did above when using
the array, then the fault goes away.  However, it then gives me a
different fault but that is another question asked below.  So again,
is there something different I should be doing that can or does deal
with this?  Is it a bug?

* Finally, the last soap fault message I'm getting (alluded to above)
is one that is telling me that there was no POST data.  I see that the
SOAP envelope/body is populated with all the nodes and data the
operation is expecting but didn't ultimately get.  It seems to me that
when the SoapClient is making the remote function call, it is passing
the data as part of a GET.  Is it possible to tell the soap client
that it should use POST instead?  I don't see anything in the
documentation the deals and/or discusses this.

Any help and/or advice would be greatly appreciated!

thnx,
Christoph

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux