gpt4 book ai didi

java - Perl 客户端到 JAX-WS java 服务器问题

转载 作者:行者123 更新时间:2023-12-01 05:42:20 25 4
gpt4 key购买 nike

我有一个发布 Web 服务的 JAX-WS java 服务器

@WebService(endpointInterface="calculator.operation.Calculator")
public class CalculatorWs implements Calculator{

public String[] add(String a) {

System.out.println(a);

String[] test = {"this", "that"};
System.out.println(test);
return test;
}

}

@WebService
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT)
public interface Calculator {
String[] add(String a);
}

并且有一个 perl 客户端

use SOAP::Lite +trace => 'all';
$SOAP::Constants::PREFIX_ENV = 'soapenv';
$SOAP::Constants::PREFIX_ENC = "SOAP-ENC";
my $soap = SOAP::Lite
->service('http://localhost:8080/tomcat/calculator?wsdl')
->soapversion('1.1');
my $var = {'a' => "test"};
my $result = $soap -> add($var);

我遇到的问题是,尽管客户端接收并识别了 Java 服务器返回的值,但 Java 服务器没有接收 Perl 客户端传递的参数。

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsam="http://www.w3.org/2
007/05/addressing/metadata" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/
policy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="ht
tp://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://operation.calculator/
" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soapenv:Body><tns:add><c-gensym3
><a xsi:type="xsd:string">test</a></c-gensym3></tns:add></soapenv:Body></soapenv
:Envelope>

这是 Perl 客户端发送的 SOAP 请求。我认为这应该归咎于其构建 SOAP 请求的方式。但如果有人能帮助我解决这个问题,我将不胜感激。谢谢。

(编辑)下面是 JAX-WS 生成的 WSDL:

<?xml version="1.0" encoding="UTF-8" ?> 
- <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.3-b01-.
-->
- <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.3-b01-.
-->
- <definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss- wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://operation.calculator/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://operation.calculator/" name="CalculatorWsService">
- <types>
- <xsd:schema>
<xsd:import namespace="http://operation.calculator/" schemaLocation="http://localhost:8080/tomcat/calculator?xsd=1" />
</xsd:schema>
</types>
- <message name="add">
<part name="parameters" element="tns:add" />
</message>
- <message name="addResponse">
<part name="parameters" element="tns:addResponse" />
</message>
- <portType name="Calculator">
- <operation name="add">
<input wsam:Action="http://operation.calculator/Calculator/addRequest" message="tns:add" />
<output wsam:Action="http://operation.calculator/Calculator/addResponse" message="tns:addResponse" />
</operation>
</portType>
- <binding name="CalculatorWsPortBinding" type="tns:Calculator">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <operation name="add">
<soap:operation soapAction="" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <service name="CalculatorWsService">
- <port name="CalculatorWsPort" binding="tns:CalculatorWsPortBinding">
<soap:address location="http://localhost:8080/tomcat/calculator" />
</port>
</service>
</definitions>

最佳答案

显示 java 函数对于 java 程序员来说非常有用,您需要显示 WSDL 或示例 SOAP(读取 XML)调用...我猜,您需要的一切

my $result = $soap -> add( 'test');

您应该知道 SOAP::Simple 在 wsdl 方面比 SOAP::Lite 更好

关于java - Perl 客户端到 JAX-WS java 服务器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6797030/

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