如何通过解析WSDL文件直接创建SOAP请求?

时间:2015-04-07 09:04:12

标签: perl soap wsdl

我的任务是创建Perl脚本,该脚本可以使用提供的参数创建XML有效负载并调用SOAP调用,然后读取响应和解析参数以提供下一次使用。我是SOAP消息的新手。

我有一个WSDL文件,基于此我可以手动创建XML SOAP消息,但我认为这不是正确的方法。我也不明白如何调用SOAP调用。是的,我可以阅读文档并且已经阅读了几次,但我想问一下是否有可能通过解析WSDL文件直接创建SOAP请求。这个主题有什么可能性?

我只有它应该做的描述或伪代码,而且我是SOAP / Web服务的新手。你有什么链接可以对我有用吗?

1 个答案:

答案 0 :(得分:0)

我建议XML::Compile::WSDL11

来自文档:

use XML::Compile::WSDL11 (); 

# once in your program
my $wsdl   = XML::Compile::WSDL11->new('def.wsdl');

# XML::Compile::Schema refuses to follow "include" and
# "import" commands, so you need to invoke them explicitly.
# $wsdl->addWSDL('file2.wsdl');            # optional
# $wsdl->importDefinitions('schema1.xsd'); # optional

# once for each of the defined operations
my $call   = $wsdl->compileClient('GetStockPrice');

# see XML::Compile::SOAP chapter DETAILS about call params
my $answer = $call->(%request);
相关问题