Perl SOAP Server - Returns Strings Arrays with WSDL Compliant Names

Philluminati

Usenet Archive
Joined
Apr 16, 2008
Messages
16
Reaction score
0
Hi guys.

I have a SOAP Web Service which needs to return a string of Arrays but when it does, the SOAP Response is incorrect (or rather incompatible with .NET and my handwritten WSDL file). I have found some threads which claim to solve the problem, but with my poor knowldge of Perl, I don't know what the solution is. Can someone explain this post:

http://markmail.org/message/zhhj2ba...m3>+page:1+mid:iun5eywwjshyfocj+state:results

In simple terms?

This is my SOAP Server Function:

---- RETURN ARRAY OF STRINGS ------------

sub GetActiveUserList
{
my @usrLst = &StaticSession::getUsers;
push @usrLst, "test";
push @usrLst, "again";
`echo @usrLst >> output.txt`;
return @usrLst;
}

--- THIS IS MY WSDL WHICH TELLS THE CLIENT TO EXPECT BACK AN ARRAY OF STRINGS ----

<?xml version="1.0" encoding="UTF-8"?>

<definitions name="AMSession"
targetNamespace="http://wwwpreview.centrinet.co.uk/~ptaylor/ poc2/AMSession.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://wwwpreview.centrinet.co.uk/~ptaylor/poc2/ AMSession.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://wwwpreview.centrinet.co.uk/~ptaylor/poc2/ AMSession.wsdl"

<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://wwwpreview.centrinet.co.uk/~ptaylor/ poc2/AMSession.wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

<complexType name="ArrayOfString">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType"
wsdl:arrayType="string"/>
</restriction>
</complexContent>
</complexType>
</schema>
</types>

<message name="void">
</message>

<message name="loginParams">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
</message>

<message name="sessionKey">
<part name="sessionkey" type="xsd:string" />
</message>

<message name="getVersionRetval">
<part name="retval" type="xsd:string" />
</message>

<message name="returnValue">
<part name="s-gensym?" type="tns:ArrayOfString" />
<!-- <part name="s-gensym5" type="xsd:string" />
<part name="s-gensym7" type="xsd:string" /> -->
</message>

<portType name="amsession_port_type">
<operation name="Login">
<input message="tns:loginParams" />
<output message="tns:sessionKey" />
</operation>
<operation name="Logout">
<input message="tns:sessionKey" />
<output message="tns:void" />
</operation>
<operation name="GetActiveUserList">
<input message="tns:void" />
<output message="tns:returnValue" />
</operation>
<operation name="GetServerVersion">
<input message="tns:void" />
<output message="tns:getVersionRetval" />
</operation>
</portType>

<binding name="amsession_binding" type="tns:amsession_port_type"> <soap:binding style="rpc" transport="http:// schemas.xmlsoap.org/soap/http" />

<operation name="Login">
<soap:eek:peration soapAction="urn:AMSession#Login" />
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="urn:AMSession" use="encoded" /> </input> <output> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="urn:AMSession" use="encoded" /> </output> </operation>

<operation name="Logout">
<soap:eek:peration soapAction="urn:AMSession#Logout" />
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="urn:AMSession" use="encoded" /> </input> <output> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="urn:AMSession" use="encoded" /> </output> </operation>

<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="urn:AMSession" use="encoded" /> </input> <output> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="urn:AMSession" use="encoded" /> </output> </operation> <operation name="GetServerVersion"> <soap:eek:peration soapAction="urn:AMSession#GetServerVersion" /> <input> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="urn:AMSession" use="encoded" /> </input> <output> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="urn:AMSession" use="encoded" /> </output> </operation> </binding>

<service name="SessionService">
<documentation>Allows users to validate and get session keys for accessing subsystems</documentation> <port binding="tns:amsession_binding" name="amsession_port"> <soap:address location="http://wwwpreview.centrinet.co.uk/cgi-bin/ poc2/AMSession.cgi" /> </port> </service> </definitions>

--- THIS IS MY CLIENT IN VB.NET ---

Public Class Form1

Dim server As SessionService

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'create a new variable to represent the server.
server = New SessionService
End Sub

Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuery.Click

Dim users As String = server.GetActiveUserList

lstUsers.Items.Clear

'lstUsers.Items.Add(users.ToString)

If (users Is Nothing) Then Exit Sub

For Each user As String In users
lstUsers.Items.Add(user)
Next

End Sub
End Class

--- It gets "There is an Error in the XML document Exception". When I run a soap client with debugging on...this is the message I get in each direction:

-------------- XML REQUEST -----------------------------

Subroutine LWP::UserAgent::redirect_ok redefined at /usr/lib/perl5/ site_perl/5.8.5/SOAP/Transport/HTTP.pm line 41.
Subroutine LWP::protocol::collect redefined at /usr/lib/perl5/ site_perl/5.8.5/SOAP/Transport/HTTP.pm line 59.
SOAP::Transport::HTTP::Client::send_receive: POST
http://wwwpreview.centrinet.co.uk/cgi-bin/poc2/AMSession.cgi HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 421
Content-Type: text/xml; charset=utf-8
SOAPAction: "AMSession#GetActiveUserList"

---XML RESPONSE -------

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http:// schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/ XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/ envelope/"><soap:Body><GetActiveUserList xmlns="AMSession" xsi:nil="true" /></soap:Body></soap:Envelope>
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
Connection: close
Server: Apache/2.0.52 (CentOS)
Content-Length: 539
Content-Type: text/xml; charset=utf-8
Client-Date: Thu, 08 May 2008 10:33:48 GMT
Client-Peer: 10.254.254.168:80
Client-Response-Num: 1
SOAPServer: SOAP::Lite/Perl/0.70_04

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http:// schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/ XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/ envelope/"><soap:Body><GetActiveUserListResponse xmlns="AMSession"><s- gensym3 xsi:type="xsd:string">test</s-gensym3><s-gensym5 xsi:type="xsd:string">again</s-gensym5></GetActiveUserListResponse></ soap:Body></soap:Envelope>

Any help would really be appreciated.

Phill
 

Ben Bullock

Usenet Archive
Joined
Jul 13, 2005
Messages
286
Reaction score
0
Philluminati said:
I have a SOAP Web Service which needs to return a string of Arrays but when it does, the SOAP Response is incorrect (or rather incompatible with .NET and my handwritten WSDL file). I have found some threads which claim to solve the problem, but with my poor knowldge of Perl, I don't know what the solution is. Can someone explain this post:
sub GetActiveUserList
{
my @usrLst = &StaticSession::getUsers;
push @usrLst, "test";
push @usrLst, "again";
`echo @usrLst >> output.txt`;
return @usrLst;
}

There doesn't seem to be anything wrong with this, but the XML you showed wasn't generated by this routine anyway.
--- It gets "There is an Error in the XML document Exception". When I run a soap client with debugging on...this is the message I get in each direction:

The only thing I can say is that this is not a problem with the above Perl routine, although it might be a problem with some other Perl somewhere else which you didn't show, or it might be an XML problem or a Visual Basic problem or something.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top