Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

XML::Compile Changing Server Endpoint

by jdudleyh (Novice)
on Jun 28, 2013 at 21:28 UTC ( #1041350=perlquestion: print w/ replies, xml ) Need Help??
jdudleyh has asked for the wisdom of the Perl Monks concerning the following question:

I have a script using XML::Compile (SOAP/WSDL 1.1) that is working fairly well. My only problem is, the connection is based on the SOAP address in the WSDL. I need the flexibility to change between different test servers. I've tried the following (amongst other things) to change the server without success:

my $call = $wsdl->compileClient ( operation=>'ServiceRequest', transport=>XML::Compile::Transport::SOAPHTTP->new ( address=>'http://new.server.name:18082/ServiceRequest' ), );

Overriding the value here generates a 404 Not Found.

Comment on XML::Compile Changing Server Endpoint
Download Code
Re: XML::Compile Changing Server Endpoint
by runrig (Abbot) on Jun 28, 2013 at 21:40 UTC
    Are you using a WSDL file? Are there 'wsdl:port' elements in there? If so, I think all you would have to do is supply different 'port' parameters (which is confusing to me, because you have no 'port' parameter, and I have them in all of my XML::Compile SOAP code). Or can you add additional ports to the wsdl file, or create 'test' versions of the wsdl file...

    Update: I see now...'port' is only required when there are multiple ports defined, and I must be currently using only SOAP api's with multiple ports. Then perhaps an answer for you might be to just create alternate test wsdl files with alternate ports, or multiple ports or something...

Re: XML::Compile Changing Server Endpoint
by Anonymous Monk on Jun 29, 2013 at 03:53 UTC

      After a lot of experimenting I've determined that when I override the "address", I lose the definition of "SOAPAction". I try to define it by adding "action=>....", but I still get 404 error (and I don't see it in the "$trace -> printRequest;" output).

      If I don't override the server address (using the one in the WSDL) and specify the correct action, the request works fine.
      If I don't override the server address and specify a bogus action, I get a 404 error (as expected).
      If I override the server address with the same address (just to test) and specify the correct action, I unexpectedly get a 404 error.

      The trace of the request -- using the endpoint address in the WSDL (which works):
      Request: POST http://address.of.server1:18082/ServiceRequest HTTP/1.1 User-Agent: libwww-perl/6.04 Content-Length: 1178 Content-Type: text/xml; charset="utf-8" SOAPAction: "/Processes/ServiceRequest" X-LWP-Version: 6.04 X-XML-Compile-Cache-Version: 0.994 X-XML-Compile-SOAP-Version: 2.36 X-XML-Compile-Version: 1.34 X-XML-LibXML-Version: 2.0018
      The trace of the request -- using the same endpoint address and action, but specified in the calls (which doesn't work):
      Request: POST http://address.of.server1:18082/ServiceRequest HTTP/1.1 User-Agent: libwww-perl/6.04 Content-Length: 1178 Content-Type: text/xml; charset="utf-8" X-LWP-Version: 6.04 X-XML-Compile-Cache-Version: 0.994 X-XML-Compile-SOAP-Version: 2.36 X-XML-Compile-Version: 1.34 X-XML-LibXML-Version: 2.0018

      I need to be able to pass in different server names and override the one in the WSDL. I'd rather avoid the ugliness of multiple copies of the same WSDL as I have many other web services as well.

        I need to be able to pass in different server names and override the one in the WSDL.

        Just throwing out ideas for workarounds...but if you parse the wsdl yourself ( with XML::LibXML->load_xml(..) ) and replace the port/address/@location, you can just pass the LibXML Node object instead of the file to addWSDL() ( or ..::WSDL->new() ). XML::Compile handles more than just files passed to its object constructors.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1041350]
Approved by kcott
Front-paged by runrig
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2014-11-28 05:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (193 votes), past polls