php如何传递map类型给JAVA webservice,求高手看下为什么JAVA服务端接收不到参数

bsb654321 2009-11-24 04:27:00
PHP客户端 用的nusoap


require_once("./nusoap/lib/nusoap.php");
$wsdl="http://localhost:8888/HelloWorld/services/HelloWorldService?WSDL";

$client=new soapclient($wsdl,true);
$proxy=$client->getProxy();
$param=array("message"=>"测试","name"=>"xxx","password"=>"12345");
$str2=$proxy->test2(array('map'=>$param));
var_dump($str2);



java端 xfire的webservice

public class HelloWorldServiceImpl {

public String test(String message) {
System.out.println("asdasda");
return message;
}

public Map test2(Map map) {
Map map2=new HashMap();
Object message= map.get("message");
Object name= map.get("name");
Object password= map.get("password");
map2.put("message", message);
map2.put("name", name);
map2.put("password", password);
System.out.println(map.size());
return map2;
}


}

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xfire.codehaus.org/config/1.0">

<service>
<name>HelloWorldService</name>
<serviceClass>
com.my.webservice.HelloWorldServiceImpl
</serviceClass>
<implementationClass>
com.my.webservice.HelloWorldServiceImpl
</implementationClass>
<style>wrapped</style>
<use>literal</use>
<scope>application</scope>
</service></beans>


WSDL

<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://webservice.my.com" xmlns:tns="http://webservice.my.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://webservice.my.com">
- <xsd:complexType name="anyType2anyTypeMap">
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" minOccurs="0" name="entry">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="key" type="xsd:anyType" />
<xsd:element maxOccurs="1" minOccurs="0" name="value" type="xsd:anyType" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
- <xsd:element name="test2">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="map" nillable="true" type="tns:anyType2anyTypeMap" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="test2Response">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="tns:anyType2anyTypeMap" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="test">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="message" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="testResponse">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="testResponse">
<wsdl:part name="parameters" element="tns:testResponse" />
</wsdl:message>
- <wsdl:message name="testRequest">
<wsdl:part name="parameters" element="tns:test" />
</wsdl:message>
- <wsdl:message name="test2Request">
<wsdl:part name="parameters" element="tns:test2" />
</wsdl:message>
- <wsdl:message name="test2Response">
<wsdl:part name="parameters" element="tns:test2Response" />
</wsdl:message>
- <wsdl:portType name="HelloWorldServicePortType">
- <wsdl:operation name="test2">
<wsdl:input name="test2Request" message="tns:test2Request" />
<wsdl:output name="test2Response" message="tns:test2Response" />
</wsdl:operation>
- <wsdl:operation name="test">
<wsdl:input name="testRequest" message="tns:testRequest" />
<wsdl:output name="testResponse" message="tns:testResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="HelloWorldServiceHttpBinding" type="tns:HelloWorldServicePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="test2">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="test2Request">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="test2Response">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="test">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="testRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="testResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="HelloWorldService">
- <wsdl:port name="HelloWorldServiceHttpPort" binding="tns:HelloWorldServiceHttpBinding">
<wsdlsoap:address location="http://localhost:8888/HelloWorld/services/HelloWorldService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>



PHP端传递一个键值对对应的数组到JAVA端,普通类型字符串 整型都能接到,现在JAVA端参数类型是MAP的时候 无法接收
map.size()查看MAP 键值对映射数量 是0

哪位高手帮忙看看是哪出问题了,

还有之前如果不使用代理类的话,始终报Not enough message parts were received for the operation.

使用代理类,传递参数的时候 必须使用数组形式传参,键和java端的参数名要一致
...全文
186 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bsb654321 2009-11-24
  • 打赏
  • 举报
回复
早试过了,没用 还是接不到
wisword 2009-11-24
  • 打赏
  • 举报
回复
$str2=$proxy->test2(array('map'=>$param));
改成
$str2=$proxy->test2($param);

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧