Thank you for this recommendation. SOAP::WSDL does, in fact, seem to have been designed for this problem.
I was able to get the simple methods to work using the WSDL, which saves some grief in terms of rolling my own XML. Unfortunately, again, I got hung up on the complex types, and the error messages produced aren't very elaborate. It seems that when I call a method that involves complex types, the WSDL is not able to resolve the definitions. I suspect this is because of a corporate firewall, but I'm not sure.
Here's the code I have so far (somewhat sanitized):
#!/usr/local/bin/perl
use strict;
use warnings;
use SOAP::WSDL +trace => 'all';
use Data::Dumper;
Main: {
my $soap=SOAP::WSDL->new( wsdl => 'http://some_ip/wsdl/myServiceName
+.wsdl' );
$soap->proxy('http://some_ip:port/some/path/myServiceLocation');
$soap->servicename('myServiceName');
$soap->wsdlinit( caching => 1);
my $response;
eval { # this one worked with no troubles
$response = $soap->call( 'queryItem' ,
id => 'blah' ,
pwd => 'bleh',
itemId => '9015');
};
if ($@) {
print "SOAP call failed: $@\n";
exit;
}
eval { # this one fails with the "error processing WSDL" message
$response = SOAP_add_Item($soap);
};
if ($@) {
print "SOAP call failed: $@\n";
exit;
}
if ($response->fault) {
print Dumper($response->faultdetail), "\n";
}
else {
my $body = $response->result;
unless ($body == 0) {
print "SOAP Message: ", Dumper($body);
}
}
}
sub SOAP_add_Item {
my $soap = shift;
my $response = $soap->call('addItem',
'id' => 'blah',
'pwd' => 'bleh',
'itemId' => '1234',
'itemName' => 'Test Item',
'Ranges' => [
{ 'min' => '8605118310',
'max' => '8605118319' } ] );
return $response;
}
# 'Ranges' => [
# bless( {
# 'min' => '8605118310',
# 'max' => '8605118319'
# }, 'SoapTypeRange' ) ] );
I've tried the complex 'Ranges' type with and without the reference to the type 'SoapTypeRange', but in neither case does it seem to be able to resolve the type.
Instead, I get this message:
SOAP call failed: Error processing WSDL: './/xsd:element' not found at
+ /usr/local/lib/perl5/site_perl/5.8.6/SOAP/WSDL.pm line 504.
That line in WSDL.pm seems to be in the context of attempting to resolve definitions for complex types. The relevant lines in the WSDL seem to be:
<wsdl:definitions name="myServiceName"
targetNamespace="http://some_ip/wsdl/myServiceName/"
xmlns:tns="http://some_ip/wsdl/myServiceName/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http:
+//schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://
+schemas.xmlsoap.org/wsdl/mime/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="
+http://schemas.xmlsoap.org/wsdl/"
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://some_ip/package/various.other.soap.types
/">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:complexType name="SoapTypeRange">
<xsd:all>
<xsd:element name="min" type="xsd:long" />
<xsd:element name="max" type="xsd:long" />
</xsd:all>
</xsd:complexType>
<xsd:complexType name="ArrayOfSoapTypeRange">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="n11:SoapTypeRan
+ge[]" />
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
I'm stumped. If I can't get outside the firewall to resolve the complex type definitions, then how can I build a workable SOAP call to this service? Any additional thoughts are very welcome.
No good deed goes unpunished. -- (attributed to) Oscar Wilde
|