Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling functions with parameters using SOAP with Perl
    text
    copied!<p>I am attempting to access a web service using SOAP through Perl and am having issues calling the service's functions that require parameters. The XSD that dictates the SOAP call says,</p> <pre><code>&lt;xs:complexType name="getVersion"&gt; &lt;xs:sequence/&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="getVersionResponse"&gt; &lt;xs:sequence&gt; &lt;xs:element minOccurs="0" name="return" type="xs:string"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; ... &lt;xs:complexType name="enumerateEntities"&gt; &lt;xs:sequence&gt; &lt;xs:element name="entityId" type="xs:int"/&gt; &lt;xs:element minOccurs="0" name="entityType" type="tns:entityType"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="enumerateEntitiesResponse"&gt; &lt;xs:sequence&gt; &lt;xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:int"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; </code></pre> <p>According to the docs for the service, the signatures for the two functions are:</p> <pre><code>String getVersion () int[] enumerateEntities (int entityId, EntityType entityType) </code></pre> <p>I am able to call the first function, which requires no input parameters, using:</p> <pre><code>#!/usr/bin/perl use SOAP::Lite; my $uri = 'http://wsdl.mydomain.com/'; my $service = SOAP::Lite -&gt; uri($uri) -&gt; on_action(sub { sprintf '"Call by on_action: %s"',shift}) -&gt; proxy('http://192.168.1.100:8688/MyService/services/MyService.MyServicePort/'); $method = SOAP::Data-&gt;name("MyService")-&gt;attr({xmlns =&gt; $uri}); $getVersion = SOAP::Data-&gt;name("getVersion")-&gt;attr({xmlns=&gt;$uri});#line 11 my $theResult = $service-&gt;getVersion; unless ($theResult-&gt;fault){ print "Version: "; print $theResult-&gt;result;} else {print $theResult-&gt;faultstring;} </code></pre> <p>...but my attempt (below) at calling a function with parameters by changing line 11 on have been futile.</p> <pre><code>... @entityId = SOAP::Data-&gt;type('int')-&gt;name('entityId')-&gt;value(0); @entityType = SOAP::Data-&gt;type('EntityType')-&gt;name('entityType')-&gt;value(NODE); $enumerateEntities = SOAP::Data-&gt;name("enumerateEntities",@entityId,@entityType)-&gt;attr({xmlns=&gt;$uri}); my $result2 = $service-&gt;enumerateEntities; print $result2-&gt;result; </code></pre> <p>What am I doing wrong that is preventing me from calling functions of the service with parameters? </p> <hr> <p><strong>Edit:</strong> Here's the updated sample code with using SOAP::WSDL</p> <pre><code>#!/usr/bin/perl use SOAP::WSDL; use Data::Dumper; my $service = SOAP::WSDL-&gt;new( wsdl =&gt; 'http://192.168.1.100:8688/MyService/services/MyService.MyServicePort?wsdl', outputhash =&gt; 1 ); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload