gpt4 book ai didi

当 Perl 的 SOAP::Lite 模块查询时,Java JAX-WS 服务返回 SOAP 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:35:50 24 4
gpt4 key购买 nike

我有一个简单的 Java 服务来获取当前时间。

我写了一个 Perl 客户端来访问它。

#! /usr/bin/perl -w
use SOAP::Lite;
my $url = 'http://127.0.0.1:9876/ts?wsdl';
my $service = SOAP::Lite->service($url)->soapversion('1.1');

print "\nCurrent time is: ", $service->getTimeAsString();
print "\nElapsed milliseconds from the epoch: ", $service->getTimeAsElapsed();

一旦客户端发出调用(也在同一台机器上),服务就会记录下面的异常,并向客户端返回 SOAP 错误而不是预期的响应。

Nov 05, 2011 11:20:34 AM com.sun.xml.internal.ws.transport.http.HttpAdapter$Http Toolkit handle
SEVERE: Couldn't create SOAP message. Expecting Envelope in namespace http://sch
emas.xmlsoap.org/soap/envelope/, but got http://schemas.xmlsoap.org/wsdl/soap/
com.sun.xml.internal.ws.protocol.soap.VersionMismatchException: Couldn't create
SOAP message. Expecting Envelope in namespace http://schemas.xmlsoap.org/soap/en
velope/, but got http://schemas.xmlsoap.org/wsdl/soap/
at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCod ec.java:167)
at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCod ec.java:292)
at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCod ec.java:118)
at com.sun.xml.internal.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:343)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:321)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.access$400(HttpAdapter.java:81)
at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:576)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(WSHttpHandler.java:95)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(WSHttpHandler.java:80)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:80)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:665)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:637)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

知道为什么吗?

最佳答案

有点晚了,但对于其他遇到此问题的人来说,问题是 SOAP::Lite 盲目地从 WSDL 文件中导入 namespace 并根据那里使用的前缀覆盖它自己的 namespace ,包括它使用的 namespace 发送 SOAP 信封本身。

解决方案是使用 envprefix 方法让它为 SOAP 信封使用不同的命名空间前缀。例如:

my $service = SOAP::Lite->service($url)->soapversion('1.1')->envprefix('S');

关于当 Perl 的 SOAP::Lite 模块查询时,Java JAX-WS 服务返回 SOAP 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8022511/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com