SOAP::Lite 生成“溢出”关于复杂类型“Array”

发布于 2025-01-07 15:26:59 字数 990 浏览 1 评论 0原文

我使用 SOAP::Lite 与“SOAP”-Service-WSDL(ASMX resp)进行通信。 该服务需要一个参数数组,如下所示:

<scriptParameters>
  <string>string</string>
  <string2>string2</string2>
</scriptParameters>

在 Perl 中,我使用以下代码:

my @args;
my @params;
foreach (keys %{$self->{args}}) {
    push(@params, SOAP::Data->name($_ => $self->{args}->{$_})->type(""));
}
push(@data, SOAP::Data->name("scriptParameters" => SOAP::Data->value(\@params)->type(""))->type(""));

但这会创建以下 XML:

<scriptParameters soapenc:arrayType="xsd:anyType[11]" xsi:type="namesp20">
  <job_id xsi:type="xsd:int">18381</job_id>
  <dump xsi:type="xsd:int">0</dump>
</scriptParameters

注意 scriptParameters-Element 中的 soapenc:arrayType... -stuff。

现在的问题是,ASMX服务无法识别scriptParameters数组(我认为是因为soapenc-stuff(不幸的是,这是不可调试的)。有谁知道我如何摆脱额外的数据?

谢谢 :)

I use SOAP::Lite to communicate to a "SOAP"-Service-WSDL (ASMX resp).
This Service requires an array of arguments, like so:

<scriptParameters>
  <string>string</string>
  <string2>string2</string2>
</scriptParameters>

In Perl I use the following code:

my @args;
my @params;
foreach (keys %{$self->{args}}) {
    push(@params, SOAP::Data->name($_ => $self->{args}->{$_})->type(""));
}
push(@data, SOAP::Data->name("scriptParameters" => SOAP::Data->value(\@params)->type(""))->type(""));

But this creates the following XML:

<scriptParameters soapenc:arrayType="xsd:anyType[11]" xsi:type="namesp20">
  <job_id xsi:type="xsd:int">18381</job_id>
  <dump xsi:type="xsd:int">0</dump>
</scriptParameters

Note the soapenc:arrayType...-stuff in the scriptParameters-Element.

The problem now is, that the ASMX-Service does not recognize the scriptParameters array (I think because of the soapenc-stuff (unfortunately this is not debug'able). Does anyone has an idea how I can get rid of the additional data?

Thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘿咻 2025-01-14 15:26:59

在不了解实际服务并且无法尝试各种选项的情况下,这有点困难。但根据我的经验,使用“soapenc:arrayType”是 SOAP::Lite 认为该服务是 RPC/编码 SOAP 服务而不是文档/文字或 RPC/文字的症状。因此,请检查您使用哪种方法来创建服务代理,“$soap->service($WSDL)”方法假定 RPC/encoded,但“$soap->proxy()”方法允许更多控制,在一些额外的复杂性的成本。

说服 SOAP::Lite 生成正确的 XML 可能有点棘手。请查看以下站点,了解有关如何使用 SOAP::Lite 构造特定数据结构的一些提示:

从后面开始,EB-eye Web 服务 (ebeye_soaplite.pl) 的示例代码为可能是最有帮助的,因为它大量使用列表/数组。

根据您与 SOAP::Lite 的联系程度,您可能想看看替代方案。我发现 XML::Compile::SOAP 与使用复杂类型的文档/文字 SOAP 服务一起使用要容易得多。

Without knowing the actual service and not being able to experiment with various options this is a bit difficult. But in my experience the use of "soapenc:arrayType" is symptomatic of SOAP::Lite thinking that the service is an RPC/encoded SOAP service rather than document/literal or RPC/literal. So check which method you are using to create the service proxy, the '$soap->service($WSDL)' method assumes RPC/encoded, but '$soap->proxy()' method allows more control, at the cost of some additional complexity.

Persuading SOAP::Lite to produce the right XML can be a bit tricky. Have a look at the following sites for some hints on how to construct specific data structures using SOAP::Lite:

From the later the sample code for the EB-eye web service (ebeye_soaplite.pl) is likely to be the most helpful since it uses lists/arrays a lot.

Depending on how tied to SOAP::Lite you are, you might want to have a look at the alternatives. I've found XML::Compile::SOAP to be quite a bit easier to use with document/literal SOAP services which use complex types.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文