使用基于WSDL的SOAP :: Lite

时间:2015-08-05 16:32:41

标签: perl authentication soap wsdl

我是SOAP :: Lite的新手,并试图通过quick start。我有一个支持SOAP的JAMA服务器(需求收集应用程序),我正在查看它的WSDL。

我在WSDL中可以获得SOAP :: Lite所需的信息(特别是代理和命名空间/ uri)吗?

WSDL包含:

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 $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.

PERL代码我有一些运行:

function calendar2(result1){
    //alert(result1);
    var calendar = $('#event_calendar');
    calendar.empty();
    calendar.fullCalendar({
        header: {
            left: 'title',
            right: 'month,agendaWeek,agendaDay today prev,next'
        },

        //defaultView: 'basicWeek',

        editable: false,
        firstDay: 0,
        height: 600,
        droppable: false,
        events: result1,

我传递给getVersion()的参数肯定是错的,是否足以导致函数什么都不返回?我以为它至少会给我带来某种错误......

2 个答案:

答案 0 :(得分:2)

我使用SOAP :: Lite与.NET Web服务(* .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格式的网络服务,但也许会有!

答案 1 :(得分:2)

我发现了神奇的命令:

$soap->outputxml('true');

所以现在我可以看到,当我用无效参数调用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>

所以即使WSDL没有帮助学习参数应该是什么,文档说它是WsAuth对象,所以现在我只需要弄清楚如何创建其中一个。