我正在尝试使用模块XML::Compile::WSDL11
在wsdl文件的基础上创建SOAP消息。
在xsd定义中有一个名为UserArea
的参数,它应该包含任意字段(扩展名):
<xsd:element name="UserArea" type="UserAreaType"/>
<xsd:complexType name="UserAreaType">
<xsd:sequence>
<xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
所以我可以手动创建一个有效的xml,如:
<ProcessAssessmentOrder>
...
<DataArea>
...
<AssessmentOrder>
...
<UserArea xmlns:xxx="http://example.com">
<xxx:someURL>http://someurl.example.com</xxx:someURL>
</UserArea>
</AssessmentOrder>
</DataArea>
</ProcessAssessmentOrder>
这有效并且有效。
但是,尝试使用XML::Compile::WSDL11
我收到错误:
mistake: tag `xxx:SomeURL' not used at {http://www.hr-xml.org/3}ProcessAssessmentOrder/DataArea/AssessmentOrder/CustomerParty/PartyReportingIDs/UserArea
参数不在生成的xml中。
到目前为止,这是我的Perl代码:
use strict;
use warnings;
use DateTime;
use XML::Compile::Transport::SOAPHTTP;
use XML::Compile::SOAP11;
use XML::Compile::WSDL11;
my %args = (
releaseID => '3.3',
ApplicationArea => {
CreationDateTime => DateTime->now,
},
DataArea => {
Process => {},
AssessmentOrder => {
UserArea => {
'xxx:SomeURL' => 'www.example.com',
},
},
},
);
my $wsdl_path = '/home/david/HR-XML-3_3/Assessments/org_hr-xml/3_3/WebServices/WSDL/AssessmentOrder.wsdl';
my $wsdl = XML::Compile::WSDL11->new($wsdl_path);
import_definitions($wsdl, '/home/david/HR-XML-3_3/Assessments/');
$wsdl->compileCalls(
port => 'AssessmentOrder_Port',
endpoint => 'http://127.0.0.1/xxx',
);
my($response, $trace) = $wsdl->call('ProcessAssessmentOrder', %args);
sub import_definitions {
my($wsdl, $path) = @_;
opendir (my $dh, $path);
while (my $file = readdir($dh)) {
next if ($file eq '.' || $file eq '..');
if (-d "$path/$file") {
import_definitions($wsdl, "$path/$file");
}
elsif ($file =~ m#\.xsd$#) {
$wsdl->importDefinitions("$path/$file");
}
}
closedir($dh);
};
如何使xml具有行
<xxx:someURL>http://someurl.example.com</xxx:someURL>
¿·_·?
答案 0 :(得分:0)
哟可以尝试添加这个:
my $myns = 'http://example.com';
$wsdl->prefixes => { $myns => [ uri => $myns, prefix => 'xxx' ] };
答案 1 :(得分:0)
如果我在http://lists.scsys.co.uk/pipermail/xml-compile/2009-July/000250.html读取内容,我认为XML :: Compile不支持xsd:any元素。除此之外,我不能说,因为我自己也在尝试类似的问题。