Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Perl: how to passed the XML string into SOAP::Data method

 
Rajeshwar Sharma
Occasional Contributor

Perl: how to passed the XML string into SOAP::Data method

How to Passed the "xml string" parameter into the SOAP::Data method in perl?, Plz help me as soon as. thanks in advance.
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor

Re: Perl: how to passed the XML string into SOAP::Data method

Hi:

You might begin by reading the module's documentation.

Regards!

...JRF...
Ralph Grothe
Honored Contributor

Re: Perl: how to passed the XML string into SOAP::Data method

Your question is a bit too unspecific.
It really depends if and in what way you need to serialize your XML entity.
The general usage of class SOAP::Data can be viewed as usual by perldoc SOAP::Data
or here
http://search.cpan.org/~mkutter/SOAP-Lite-0.710.08/lib/OldDocs/SOAP/Lite.pm#SOAP::Data

The easiest I would think was to use a WSDL file for the SOAP service you need to communicate with.
From own bad experience when I tried to communicate with an Apache Axis SOAP server I do remember that WSDL support in the old SOAP::Lite was barely existing or working at all.
Basically the SOAP::Lite modules was more or less only useful if you implemented server and client with this module while interoperability with newer SOAP services was really nerve wrecking.
I heard at this year's German Perl Workshop that Soap::Lite now has a new maintainer, viz. Martin Kutter who took over from Pavel Kulchenko.
Martin promised that he wants to overhaul the whole SOAP::Lite and provide it with working WSDL capability which should make the whole stuff a hell of a lot easier for the average module user.
On CPAN I found this module by him.
Maybe it is already usable?
You could give it a try and report.
http://search.cpan.org/dist/SOAP-WSDL/
Madness, thy name is system administration
Rajeshwar Sharma
Occasional Contributor

Re: Perl: how to passed the XML string into SOAP::Data method

Hi,
I am using SOAP::Lite module for perl client which connect the web services.
I am using SOAP::Data method as :
"SOAP::Data->name('string')->value($XML)"for a method
Here $xml is a XML string, when i passed this parameter i got 400 bad error.if i used XML::Simple and XML::Dumper module which convert the xml string into perl data ,and use this perl data into the value of SOAP::Data,but i am not able to execute my method

So, can any idea about how to passed the "xml" string in above quotted method.
Ralph Grothe
Honored Contributor

Re: Perl: how to passed the XML string into SOAP::Data method

> I am using SOAP::Data method as :
>"SOAP::Data->name('string')->value($XML)"for a method
> Here $xml is a XML string

No, I don't think you are supposed to pass verbatim XML like that. The SOAP serializer is converting into valid XML for you.
SOAP::Data has accessor and mutator methods (or getters and setters if you prefer) which you would pass values like with any other Perl function. You haven't read perdoc SOAP::Data, have you?

As a sample I attached a snippet from said Apache Axis SOAP client I once wrote which shows how it worked for me rigging up an appropriate SOAP header.
This really looks ugly but I was forced to build up the complete entity like that with iterative tcpdumps from a working .Net SOAP client.
Normally you wouldn't want to do this but use a WSDL file, as did the colleague who wrote a .Net client which unlike mine for him worked out of the box.
But this was owe to SOAP::Lite's deficiencies because it came out too early and was implemented according to early SOAP standards nobody else seems to use anymore.
Madness, thy name is system administration
Ralph Grothe
Honored Contributor

Re: Perl: how to passed the XML string into SOAP::Data method

I apologize, I just revisited the POD of SOAP::Data and had to discover that you indeed can pass verbatim XML.
I have never made use of this, that's why I didn't knew.
But as it reads in the POD, you have to make sure that the XML you pass is valid since the serializer won't do any checking of it.


COMPOSING MESSAGES USING RAW XML

In some circumstances you may need to encode a message using raw
unserialized XML text. To instantiate a SOAP::Data object using raw
XML, do the following:

$xml_content = "123";
$elem = SOAP::Data->type('xml' => $xml_content);

SOAP::Lite's serializer simple takes whatever text is passed to it,
and inserts into the encoded SOAP::Data element verbatim. The text
input is NOT validated to ensure it is valid XML, nor is the resulting
SOAP::Data element validated to ensure that it will produce valid XML.
Therefore, it is incumbent upon the developer to ensure that any XML
data used in this fashion is valid and will result in a valid XML
document.
Madness, thy name is system administration
Rajeshwar Sharma
Occasional Contributor

Re: Perl: how to passed the XML string into SOAP::Data method

I was used as u mention in reply , but situation is same. i have copied here the method where i used the xml as input parameter in the method.when i used the xml in value i got the error . Plz help me.
$result = $soap->call(SOAP::Data->name($strMethod)->attr({xmlns =>$uri . "/"})=>(
SOAP::Data->name('strClientId')->value($strClientId),
SOAP::Data->name('strSubjectPath')->value($strSubjectPath),
SOAP::Data->name('strQATestName')->value($strQATestName),
SOAP::Data->name('strFolderName')->value($strFolderName),
SOAP::Data->name('strXML')->value($xml_content),
SOAP::Data->name('blForce')->value($blForce),
SOAP::Data->name('blCreateFolder')->value($blCreateFolder)
)
);
thanks in advance..
raj