Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

SOAP for Perl

by TomJones (Initiate)
on Aug 03, 2004 at 08:36 UTC ( [id://379552]=perlquestion: print w/replies, xml ) Need Help??

TomJones has asked for the wisdom of the Perl Monks concerning the following question:

Hi Fellow Monks,

I'm having problems with the syntax of Soap (Soap::Lite, Soap::MIME, MIME::Entity) for perl. I've written the following piece of code: -

#!/opt/perl5/bin/perl use SOAP::Lite +trace; use SOAP::MIME; use MIME::Entity; $SOAP::Constants::DO_NOT_USE_CHARSET = 1; my $cid = "Test"; my $ent = MIME::Entity->build(Boundary => "soap-boarder", Type => "mul +tipart/related", 'Content-Id' =>"<$cid>"); print SOAP::Lite -> uri('http://www.3gpp.org/ftp/Specs/archive/23_series/23.140 +/schema/REL-5-MM7-1-2') -> on_action(sub { return "\"\""; }) -> proxy('http://10.236.137.7:10021/vas_soap') -> parts($ent) #-> SubmitReq(SOAP::Data->name("MM7Version" => '5.3.0')) -> result;

results in

mkuetk@smswxp2:~/perlScripts > perl Soap01.pl SOAP::Transport::new: () SOAP::Serializer::new: () SOAP::Deserializer::new: () SOAP::Parser::new: () SOAP::Lite::new: () SOAP::Transport::HTTP::Client::new: () SOAP::Serializer::envelope: () SOAP::Serializer::envelope: result SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x85a1 +a2c) SOAP::Transport::HTTP::Client::send_receive: POST http://10.236.137.7: +10021/vas_soap HTTP/1.1 Accept: text/xml Accept: multipart/* Content-Length: 1035 Content-Type: Multipart/Related; type="text/xml"; start="<main_envelop +e>"; boundary="----------=_1 091521171-25073-0" SOAPAction: "" This is a multi-part message in MIME format... ------------=_1091521171-25073-0 Content-Type: text/xml Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Location: /main_envelope Content-Id: <main_envelope> <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-EN +C="http://schemas.xmlsoap.or g/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/s +oap/encoding/" xmlns:SOAP-EN V="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3 +.org/1999/XMLSchema-instance " xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1 +:result xmlns:namesp1="http: //www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2 +"/></SOAP-ENV:Body></SOAP-EN V:Envelope> ------------=_1091521171-25073-0 Content-Type: multipart/related; boundary="soap-boarder" Content-Transfer-Encoding: binary MIME-Version: 1.0 X-Mailer: MIME-tools 6.110 (Entity 6.109 ) Content-Id: <Test> This is a multi-part message in MIME format... --soap-boarder-- ------------=_1091521171-25073-0-- SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x869 +c7a4) SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Ser +ver Error Connection: close Date: Tue, 03 Aug 2004 08:24:45 GMT Server: Apache/1.3.20 (Unix) mod_ssl/2.8.4 OpenSSL/0.9.6 Content-Type: text/html; charset=iso-8859-1 Client-Date: Tue, 03 Aug 2004 08:19:32 GMT Client-Response-Num: 1 Client-Transfer-Encoding: chunked Title: 500 Internal Server Error <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>500 Internal Server Error</TITLE> </HEAD><BODY> <H1>Internal Server Error</H1> The server encountered an internal error or misconfiguration and was unable to complete your request.<P> Please contact the server administrator, mmscadm@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.<P> More information about this error may be available in the server error log.<P> </BODY></HTML> SOAP::Deserializer::deserialize: () SOAP::Parser::decode: () 500 Internal Server Error at /usr/local/lib/perl5/site_perl/5.6.1/SOAP +/MIME.pm line 207 SOAP::Lite::DESTROY: () SOAP::Transport::DESTROY: () SOAP::Transport::HTTP::Client::DESTROY: () SOAP::Deserializer::DESTROY: () SOAP::Serializer::DESTROY: () SOAP::Data::DESTROY: () SOAP::Data::DESTROY: () SOAP::Data::DESTROY: () SOAP::Data::DESTROY: () SOAP::Parser::DESTROY: ()

but this is useless and I need

POST /vas_soap HTTP/1.0 Content-Type: multipart/related; boundary="soap-border"; type="text/xm +l"; start="Test" Content-Length: 2749 Authorization: Basic NDM2NjQxMjMxMjM0OjEyMzQ= SOAPAction: "" --soap-border Content-Type: application/xml Content-ID: Test <?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/env +elope/" xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/sche +ma/REL-5-MM7-1-2"> <SOAP-ENV:Header> <TransactionID SOAP-ENV:mustUnderstand="1">TransID</TransactionI +D> </SOAP-ENV:Header> <SOAP-ENV:Body> <SubmitReq> <MM7Version>4.3.0</MM7Version> <SenderIdentification> <VASPID>436641231234</VASPID> <VASID>News</VASID> <SenderAddress> <Number>436641231234</Number> </SenderAddress> </SenderIdentification> <Recipients> <To> <Number>436643316123</Number> </To> </Recipients> <ServiceCode>gold-sp33-im42</ServiceCode> <LinkedID>mms00016666</LinkedID> <MessageClass>Personal</MessageClass> <DeliveryReport>False</DeliveryReport> <ReadReply>False</ReadReply> <Priority>Normal</Priority> <Subject>MMSC-ATP-036_2</Subject> <Content href="cid:SaturnPics-01020930@news.tnn.com" allowAda +ptations="True"/> </SubmitReq> </SOAP-ENV:Body> </SOAP-ENV:Envelope> --soap-border Content-Type: multipart/mixed; boundary="boundary

Questions:

1. Why is This is a multi-part message in MIME format... written to output. My guess is there is something wrong with my MIME::Entity object.

2. How can I modify the SOAP Envelope to produce the desired output.

A million thanks,

Tj.

Edited 3 Aug 2004, by footpad: Added <P> and <READMORE> tags, per Consideration.

Replies are listed 'Best First'.
Re: SOAP for Perl
by nite_man (Deacon) on Aug 03, 2004 at 10:09 UTC

    Why is This is a multi-part message in MIME format... written to output.
    Try to swith off 'trace' option:

    use SOAP::Lite; # instead of SOAP::Lite +trace;

    How can I modify the SOAP Envelope to produce the desired output
    What is reason to do that. You can access to the responce data as normal Perl object:

    my $res = SOAP::Lite -> uri('http://www.3gpp.org/ftp/Specs/archive/23_series/23.140 +/schema/REL-5-MM7-1-2') -> on_action(sub { return "\"\""; }) -> proxy('http://10.236.137.7:10021/vas_soap') -> parts($ent); if($res->fault) { $self->errors($result); } else { my $reqObj = $res->result; print $reqObj->ServiceCode; #gold-sp33-im42 ... }
    Also, try to see here some useful information about SOAP::Lite.

    ---
    Schiller

    It's only my opinion and it doesn't have pretensions of absoluteness!

      Thanks for responding Schiller, I've turned tracing to off and this eliminates the MIME message. The server still rejects the message, however I believe this is because the SOAP Header TransactionID is not set in the SOAP Envelope. From Soap::Lite this is set using
      SOAP::Header->name(TransactionID => TransID)->mustUnderstand(1) <CODE +> <CODE> Q. Do I know how to access the Envelope and set this header
      <CODE> Q. I'd like to set values rather than request then so for example SubmitReq(SOAP::Data->name("MM7Version" => '5.3.0'))<CODE> A million thanks. Tj.

        You can create header and body using SOAP::Serializer and pass it using SOAP::Lite method on_action:

        my $soapObj = SOAP::Lite -> uri('http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/sch +ema/REL-5-MM7-1-2') -> on_action(sub { return SOAP::Serializer->envelope(method => 'MM +7Version', '5.3.0', SOAP::Header->name(TransactionID => 5) +->mustUnderstand(1) ); }) -> proxy('http://10.236.137.7:10021/vas_soap'); print $soapObj->result;
        Result is:
        <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instanc +e" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Header> <TransactionID SOAP-ENV:mustUnderstand="1" xsi:type="xsd:int">5</Trans +actionID> </SOAP-ENV:Header> <SOAP-ENV:Body> <MM7Version> <c-gensym5 xsi:type="xsd:string">5.3.0</c-gensym5></MM7Version> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

        ---
        Schiller

        It's only my opinion and it doesn't have pretensions of absoluteness!

        Hope it helps :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://379552]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (8)
As of 2024-04-16 18:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found