For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > October 2005 > Interop between PEAR-SOAP and Visual Studio - complex types









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Interop between PEAR-SOAP and Visual Studio - complex types
Artyom Kamshilin

2005-10-21, 7:56 am

Hi everybody,

I try to register a complex type in PEAR-SOAP (array of integers), here's
the resulting WSDL:

<?xml version="1.0"?><definitions name="localhost"
targetNamespace="urn:localhost"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:localhost"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types xmlns="http://schemas.xmlsoap.org/wsdl/">
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:localhost">
<complexType name="dataObj">
<complexContent>
<restriction base="SOAP-ENC:Array">
<attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:int[]" />
</restriction>
</complexContent>
</complexType>
</schema>
</types>
<message name="retObjRequest" />
<message name="retObjResponse">
<part name="return" type="xsd:dataObj" />
</message>
<portType name="localhostPort">
<operation name="retObj">
<input message="tns:retObjRequest" />
<output message="tns:retObjResponse" />
</operation>
</portType>
<binding name="localhostBinding" type="tns:localhostPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"
/>
<operation name="retObj">
<soap:operation
soapAction="http://schemas.xmlsoap.org/soap/envelope/#ivwebservice#retObj"
/>
<input>
<soap:body use="encoded"
namespace="http://schemas.xmlsoap.org/soap/envelope/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded"
namespace="http://schemas.xmlsoap.org/soap/envelope/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="localhostService">
<documentation />
<port name="localhostPort" binding="tns:localhostBinding">
<soap:address location="http://localhost/code/web_service.php" />
</port>
</service>
</definitions>

But when this WSDL is fed into Visual Studio 2003, retObj() method is
declared as "public string retObj()" - and of course fails because returned
type (array of int) cannot be cast to a string.

I have this problem with all other registered types as well - Visual Studio
simply uses string for anything except basic types like "int", "float" etc.
Is there a way to make Visual Studio understand complex types? I'd really
appreciate any help.

Artyom
Michael Rasmussen

2005-10-21, 6:57 pm

On Fri, 21 Oct 2005 17:32:13 +0800, Artyom Kamshilin wrote:

> I have this problem with all other registered types as well - Visual Studio
> simply uses string for anything except basic types like "int", "float" etc.
> Is there a way to make Visual Studio understand complex types? I'd really
> appreciate any help.
>

You have an error in your WSDL:
<complexType name="dataObj">
<complexContent>
<restriction base="SOAP-ENC:Array">
<attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:int[]" />
</restriction>
</complexContent>
</complexType>

<message name="retObjResponse">
<part name="return" type="xsd:dataObj" />
--> here is the error: Namespace xsd has no knowledge of the type dataObj.
</message>

Change it to this:
<message name="retObjResponse">
<part name="return" type="tns:dataObj" />
</message>

Reason: dataObj is declared in your own namespace which is referenced
in the namesspace xmlns:tns="urn:localhost" and can be referenced via tns.

--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/...arch=0xE3E80917
Artyom Kamshilin

2005-10-22, 6:57 pm

> > I have this problem with all other registered types as well
> - Visual
> like "int", "float" etc.
> You have an error in your WSDL:
> <complexType name="dataObj">
> <complexContent>
> <restriction base="SOAP-ENC:Array">
> <attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:int[]" />
> </restriction>
> </complexContent>
> </complexType>
>
> <message name="retObjResponse">
> <part name="return" type="xsd:dataObj" />
> --> here is the error: Namespace xsd has no knowledge of the
> type dataObj.
> </message>
>
> Change it to this:
> <message name="retObjResponse">
> <part name="return" type="tns:dataObj" /> </message>
>
> Reason: dataObj is declared in your own namespace which is
> referenced in the namesspace xmlns:tns="urn:localhost" and
> can be referenced via tns.


It worked when I change it manually - but I use SOAP_DISCO_Server() class to
generate WSDL - and it maps all my custom types to "xsd". I found that the
type namespace is assigned inside addMethodsFromMap(), and is coming from
$disco->_getTypeNs() method - and _getTypeNs() fails to determine custom
defined types, returning XSD for any type, be it custom or not. Did I miss a
certain way of defining a custom type, so that it maps to "tns"
automatically?

Thanks!

Artyom
Michael Rasmussen

2005-10-22, 6:57 pm

On Sat, 22 Oct 2005 20:57:43 +0800, Artyom Kamshilin wrote:

>
> It worked when I change it manually - but I use SOAP_DISCO_Server() class
> to generate WSDL - and it maps all my custom types to "xsd". I found that
> the type namespace is assigned inside addMethodsFromMap(), and is coming
> from $disco->_getTypeNs() method - and _getTypeNs() fails to determine
> custom defined types, returning XSD for any type, be it custom or not. Did
> I miss a certain way of defining a custom type, so that it maps to "tns"
> automatically?
>

In my experience the implementation af Disco in PEAR_SOAP is useless if
server uses nested types or use types with refences. You can overcome this
limitation by constructing your own typemaps in your server but to the
best of my knowledge it simple not worth the effort. Write you own WSDL.

If you change to PHP5 and it's soap-ext there is work in progress of
making a php2wsdl and wsdl2php which seems more reliable.

--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/...arch=0xE3E80917
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com