2011-07-22 43 views
1

我有出版web服務Perl的客戶端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); 
} 

一個JAX-WS Java服務器,有一個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服務器沒有收到Perl客戶端傳遞的參數,儘管J返回的值ava服務器被客戶端接收並識別。

<?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> 

回答

0

顯示了java功能是偉大的Java程序員,你需要顯示WSDL或樣品SOAP(讀取XML)的調用。 ..我的猜測,所有你需要

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

你應該知道SOAP ::簡單的是在WSDL比SOAP ::精簡版

+0

嘿,我沒有嘗試,還是沒能得到任何東西。我已經添加了生成的WSDL。 – user811165

0

我有同樣的問題更好。我做了以下兩個變化工作:

  1. 名稱你的論點作爲XSD(http://localhost:8080/tomcat/calculator?xsd=1
  2. 不要使用默認的命名空間,但對SOAP方法(ns()法)命名空間前綴。

示例代碼:

my $soap = SOAP::Lite            
    -> proxy('http://localhost:8080/tomcat/calculator') 
    -> ns ('http://operation.calculator/'); 

my $response = $soap->call('add', SOAP::Data->name(arg0 => 'Peter Pan'));