marcjb has asked for the wisdom of the Perl Monks concerning the following question:
The above code produces the following:#!/usr/bin/perl use SOAP::Lite +trace; my ($server, $endpoint, $soapaction, $method, $body, $envelope); $server = 'http://127.0.0.1'; $endpoint = "$server/Just_Some_Test"; $soapaction = "Just_Some_Test"; # This will eventually come from a file $body = qq~<wsap:GetData soapenv:encodingStyle="http://schemas.xmlsoap +.org/soap/encoding/"> <Just_A_String> </Just_A_String> </wsap:GetData> ~; # Set the envelope - Will eventually contain other specific stuff my $envelope = SOAP::Serializer->new(); $envelope-> register_ns ("http://www.w3.org/2001/XMLSchema-instance", +"xsi"); $envelope-> register_ns ("http://www.w3.org/2001/XMLSchema", "xsd"); # Initialize the object my $getData = SOAP::Lite -> serializer ($envelope) -> uri ($soapaction) -> readable (1) -> proxy ($endpoint) -> on_fault(sub { my($soap, $res) = @_; die ref $res ? "ERROR " . $res->faultdetail : "ERROR +" .$soap->transport->status, "\n"; }) ; # Make the call and set the Body of the message my $response = $getData->call( method => SOAP::Data->type(xml => $body +) ); if ( $response->fault ) { printf "***A fault (%s) occurred: %s\n", $response->faultcode, $response->faultstring; } else { print "***Response: " . $response->result . "\n"; } exit;
I've looked at some of the threads on setting the body to raw XML, but there always seems to be some extra tags left over. The above is almost perfect! I just need to get rid of:<?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> <method xmlns="Just_Some_Test"> <wsap:GetData soapenv:encodingStyle="http://schemas.xmlsoap.org/ +soap/encoding/"> <Just_A_String> </Just_A_String> </wsap:GetData> </method> </soap:Body> </soap:Envelope>
and it's closing tag. Can this be done?<method xmlns="Just_Some_Test">
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SOAP? Setting BODY Manually
by Anonymous Monk on Jul 17, 2008 at 03:49 UTC | |
by marcjb (Initiate) on Jul 22, 2008 at 20:29 UTC |