简体   繁体   English

使用基于WSDL的SOAP :: Lite

[英]Using SOAP::Lite based on WSDL

I'm brand new to SOAP::Lite and trying to work through the quick start . 我是SOAP :: Lite的新手,并试图通过快速入门 I have a JAMA server (requirements gathering app) that supports SOAP and I am looking at its WSDL. 我有一个支持SOAP的JAMA服务器(需求收集应用程序),我正在查看它的WSDL。

Is the information I need for SOAP::Lite available in the WSDL (specifically the proxy and the namespace/uri)? 我在WSDL中可以获得SOAP :: Lite所需的信息(特别是代理和命名空间/ uri)吗?

The WSDL contains this: 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>

For future reference, I did get this mostly working, here's 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)

The PERL code I have sort of runs: 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.

The parameters I'm passing to getVersion() are definitely wrong, is that enough to cause the function to return nothing? 我传递给getVersion()的参数肯定是错误的,是否足以导致函数什么都不返回? I had thought it would at least return me some kind of error ... 我以为它至少会给我一些错误...

I've used SOAP::Lite to talk to a .NET web-service (*.asmx format). 我使用SOAP :: Lite与.NET Web服务(* .asmx格式)进行通信。 The web-service provides a WSDL, but that's NOT what I reference in the code. 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;

Everything in there I learned from https://msdn.microsoft.com/en-us/library/ms995764.aspx . 我从https://msdn.microsoft.com/en-us/library/ms995764.aspx学到了所有内容。 Not sure if that will help you, as you might not have an asmx-format web-service, but maybe it will! 不确定这是否会对您有所帮助,因为您可能没有asmx格式的Web服务,但也许它会!

I discovered the magic command: 我发现了神奇的命令:

$soap->outputxml('true');

So now I can see that when I call that getProjects() function with an invalid parameter, it is in fact talking to the server and getting an error: 所以现在我可以看到,当我用无效参数调用getProjects()函数时,它实际上正在与服务器通信并收到错误:

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 the WSDL was no help in learning what the parameter is supposed to be, the documentation says it's a WsAuth object, so now I just have to figure out how to create one of those. 因此,即使WSDL没有帮助学习参数应该是什么,文档说它是一个WsAuth对象,所以现在我只需要弄清楚如何创建其中一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM