Using SOAP :: Lite based on WSDL

I am new to SOAP :: Lite and am trying to do a quick start quickly . I have a JAMA Server (Requirements Collection Application) that supports SOAP and I am looking at its WSDL.

Is the information required for SOAP :: Lite available in the WSDL (specifically the proxy and / uri namespace)?

WSDL contains the following:

<wsdl:definitions xmlns:ns1="http://v3.ws.contour.jamasoftware.com/"
  xmlns:ns2="http://cxf.apache.org/bindings/xformat"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:tns="http://v3.ws.contour.jamasoftware.com"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ContourSoapServiceV3"
  targetNamespace="http://v3.ws.contour.jamasoftware.com">
<wsdl:import
  location="http://MYSERVER/jama/ws/v3/soap/ContourSoapService?wsdl=ContourSoapService.wsdl"
  namespace="http://v3.ws.contour.jamasoftware.com/"/>
<wsdl:binding name="ContourSoapServiceV3SoapBinding" type="ns1:ContourSoapService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
And a little later on...
<wsdl:operation name="getProjects">
  <soap:operation soapAction="getProjects" style="document"/>
  <wsdl:input name="getProjects">
    <soap:body use="literal"/>
  </wsdl:input>
  <wsdl:output name="getProjectsResponse">
    <soap:body use="literal"/>
  </wsdl:output>
</wsdl:operation>

      

For future reference, I did get it mostly working, here is the code:

my $soap = SOAP::Lite
  -> proxy('http://MYSERVER/jama/ws/v3/soap/ContourSoapService')
  -> uri('http://v3.ws.contour.jamasoftware.com');
print "Soap is $soap\n";
# Soap is SOAP::Lite=HASH(0x7fdc24e3fb70)

      

PERL code I have several runs:

my $service = SOAP::Lite->service('http://MYSERVER/jama/ws/v3/soap/ContourSoapService?wsdl');
print "service is $service\n";
# This says service is ContourSoapServiceV3=HASH(0x7fd244804678) which is happy
# But then I can't figure out what to do with $service
my %hash = %$service;
foreach my $key (keys %hash )
{
   print "key $key\n";
}
# service is ContourSoapServiceV3=HASH(0x7f8c8bf342f8)
# key _packager
# key _transport
# key _on_fault
# key _on_nonserialized
# key _deserializer
# key _on_action
# key _autoresult
# key _schema
my $schema = $service->_schema();
print "schema is $schema\n";
# Unrecognized method '_schema'. List of available method(s):
# getDownstreamRelationships getRelationshipsForProject addAttachmentToItem
# signBaseline clearSuspectLinksForItem deactivateProject
# and eventually:
# getVersion
# and then many more
print "Version is " . $service->getVersion(3, 6) . "\n";
# Use of uninitialized value in concatenation (.) or string at ./JamaItems.perl line 66.

# And if I bypass the $service it no better:
print "Version is " . SOAP::Lite
  -> proxy('http://MYSERVER/jama/ws/v3/soap/ContourSoapService')
  -> uri('http://v3.ws.contour.jamasoftware.com')
  -> getVersion(3, 6)
  -> result . "\n";
# Use of uninitialized value in concatenation (.) or string at ./JamaItems.perl line 70.

      

The parameters I pass to getVersion () are definitely wrong, is it enough that the function doesn't return anything? I thought this would at least give me some kind of error ...

+3


source to share


2 answers


I have used SOAP :: Lite to communicate with a .NET web service (* .asmx format). The web service provides WSDL, but this is NOT what I am linking to in the code.

  my $soap = SOAP::Lite
    -> uri('http://myserver')
    -> on_action( sub { join '/', 'http://myserver', $_[1] } )
    -> proxy('http://myserver/services/GetEmailAddress/Service.asmx');

  my $method = SOAP::Data->name('GetEmailAddress')
    ->attr({xmlns => 'http://myserver/'});

  my @params = ( SOAP::Data->name(username => "someusername") ); 
  my $email = $soap->call($method => @params)->result;

      



Everything I learned from https://msdn.microsoft.com/en-us/library/ms995764.aspx . Not sure if this will help you as you may not have an asmx-format webservice, but maybe it will!

+2


source


I found the magic command:

$soap->outputxml('true');

      

So now I can see that when I call this getProjects () function with an invalid parameter, it actually talks to the server and gets the error:



my $soap = SOAP::Lite
  -> proxy('http://MYSERVER/jama/ws/v3/soap/ContourSoapService')
  -> uri('http://v3.ws.contour.jamasoftware.com');
print "Soap is $soap\n";
# Soap is SOAP::Lite=HASH(0x7fdc24e3fb70)

my $projects = $soap->getProjects(3);
print "Projects are $projects\n\n";
# Projects are <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
# <soap:Body><soap:Fault>
#   <faultcode>soap:Server</faultcode>
#   <faultstring>Access control</faultstring>
# </soap:Fault></soap:Body></soap:Envelope>

      

So even though WSDL didn't help in learning what parameter should be, the documentation says about this WsAuth object, so now I just need to figure out how to create one of them.

+2


source







All Articles