我是 SOAP::Lite 的新手,正在尝试完成 quick start .我有一个支持 SOAP 的 JAMA 服务器(需求收集应用程序),我正在查看它的 WSDL。
我需要的 SOAP::Lite 信息是否在 WSDL 中可用(特别是代理和 namespace /uri)?
WSDL 包含以下内容:
<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>
为了将来引用,我确实让这个大部分工作了,这里是代码:
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 代码:
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's 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.
我传递给 getVersion() 的参数肯定是错误的,是否足以导致函数不返回任何内容?我原以为它至少会返回某种错误...
最佳答案
我已经使用 SOAP::Lite 与 .NET 网络服务(*.asmx 格式)对话。 Web 服务提供 WSDL,但这不是我在代码中引用的内容。
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;
我从https://msdn.microsoft.com/en-us/library/ms995764.aspx学到的一切.不确定这是否对您有帮助,因为您可能没有 asmx 格式的网络服务,但也许会有帮助!
关于perl - 使用基于 WSDL 的 SOAP::Lite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31838112/