java吧 关注:1,269,035贴子:12,773,229
  • 5回复贴,共1

求教:axis 调用 cxf 服务端,传递对象总为null的问题

只看楼主收藏回复

问题描述:
服务端用cxf @webservice 注解 Endpoint.publish发布
@WebService
public class ServerImpl implements Server
{
public PutawayPackage server(PutawayPackage putawayPackage,boolean bool){
System.out.println(putawayPackage);
System.out.println("execute processPutawayPackage");
System.out.println(putawayPackage.getControlNo());
System.out.println(bool);
return putawayPackage;
}
wsdl如下:
<wsdl:definitions xmlns:xsd="htt(防吞)p://http://www.w3.org/2001/XMLSchema" xmlns:wsdl="htt(防吞)p://schemas.xmlsoap.org/wsdl/" xmlns:tns="htt(防吞)p://webservice.wcs.y3technologies.com/"xmlns:soap="htt(防吞)p://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="htt(防吞)p://schemas.xmlsoap.org/soap/http" name="ServerImplService" targetNamespace="htt(防吞)p://webservice.wcs.y3technologies.com/"><wsdl:types><xs:schema xmlns:xs="htt(防吞)p://http://www.w3.org/2001/XMLSchema" xmlns:tns="htt(防吞)p://webservice.wcs.y3technologies.com/" elementFormDefault="unqualified" targetNamespace="htt(防吞)p://webservice.wcs.y3technologies.com/"version="1.0"><xs:element name="server" type="tns:server"/><xs:element name="serverResponse" type="tns:serverResponse"/><xs:complexType name="server"><xs:sequence><xs:element form="qualified" minOccurs="0" name="putawayPackage" type="tns:putawayPackage"/><xs:element form="qualified" name="bool" type="xs:boolean"/></xs:sequence></xs:complexType><xs:complexType name="putawayPackage"><xs:sequence><xs:element minOccurs="0" name="controlNo" type="xs:string"/><xs:element minOccurs="0" name="errorMessage" type="xs:string"/><xs:element minOccurs="0" name="hubCode" type="xs:string"/><xs:element minOccurs="0" name="ownerCode" type="xs:string"/><xs:element minOccurs="0" name="processTime" type="xs:dateTime"/><xs:element minOccurs="0" name="projectCode" type="xs:string"/><xs:element minOccurs="0" name="referenceNo" type="xs:string"/><xs:element minOccurs="0" name="requestNo" type="xs:string"/><xs:element minOccurs="0" name="requestTime" type="xs:dateTime"/><xs:element minOccurs="0" name="status" type="xs:string"/></xs:sequence></xs:complexType><xs:complexType name="serverResponse"><xs:sequence><xs:element minOccurs="0" name="return" type="tns:putawayPackage"/></xs:sequence></xs:complexType></xs:schema></wsdl:types><wsdl:message name="serverResponse"><wsdl:part element="tns:serverResponse" name="parameters"></wsdl:part></wsdl:message><wsdl:message name="server"><wsdl:part element="tns:server" name="parameters"></wsdl:part></wsdl:message><wsdl:portType name="Server"><wsdl:operation name="server"><wsdl:input message="tns:server" name="server"></wsdl:input><wsdl:output message="tns:serverResponse" name="serverResponse"></wsdl:output></wsdl:operation></wsdl:portType><wsdl:binding name="ServerImplServiceSoapBinding" type="tns:Server"><soap:binding style="document" transport="htt(防吞)p://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="server"><soap:operation soapAction="" style="document"/><wsdl:input name="server"><soap:body use="literal"/></wsdl:input><wsdl:output name="serverResponse"><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="ServerImplService"><wsdl:port binding="tns:ServerImplServiceSoapBinding" name="ServerImplPort"><soap:address location="htt(防吞)p://localhost:9000/server"/></wsdl:port></wsdl:service></wsdl:definitions>
客户端用axis访问
部分代码如下
Service service = new Service();
Call call;
try
{
PutawayPackage putawayPackage = new PutawayPackage();
putawayPackage.setControlNo("ControlNo");
call = (Call) service.createCall();
call.setTargetEndpointAddress("htt(防吞)p://localhost:9000/server");
// method name
call.setOperationName(new QName("htt(防吞)p://xxx/", "server"));
QName qPutawayPackage = new QName("http:/xxx/", "PutawayPackage");
// registerTypeMapping
call.registerTypeMapping(PutawayPackage.class, qPutawayPackage, new BeanSerializerFactory(PutawayPackage.class, qPutawayPackage),
new BeanDeserializerFactory(PutawayPackage.class, qPutawayPackage));
//Parameter
call.addParameter("putawayPackage", XMLType.XSD_ANYTYPE, ParameterMode.IN);
call.addParameter("bool", XMLType.SOAP_BOOLEAN, ParameterMode.IN);
// ReturnType
call.setReturnType(qPutawayPackage);
PutawayPackage p = (PutawayPackage)call.invoke(new Object[] { putawayPackage,true });// Remote invocation
// System.out.println(call.getResponseMessage().toString());
}
catch (ServiceException e)
{
e.printStackTrace();
}
catch (RemoteException e)
{
e.printStackTrace();
}
String 和 int 简单数据类型可以正常发过去,但是对象和boolean 就一直为null
求大神分析下原因


IP属地:天津1楼2016-01-25 17:27回复
    没人 看么。。。


    IP属地:天津2楼2016-01-27 09:22
    回复
      2025-07-13 11:37:01
      广告
      初步研究发现 是因为axis发送的soap 格式是
      <?xml version="1.0" encoding="UTF-8"?>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>
      <ns1:server soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://webservice.wcs.y3technologies.com/">
      <putawayPackage href="#id0"/>
      <bool href="#id1"/>
      <str xsi:type="xsd:string">ssss</str>
      </ns1:server>
      <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:boolean" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">true</multiRef>
      <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:PutawayPackage" xmlns:ns2="http://webservice.wcs.y3technologies.com/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <controlNo xsi:type="soapenc:string">ControlNo</controlNo>
      <errorMessage xsi:type="soapenc:string" xsi:nil="true"/>
      <hubCode xsi:type="soapenc:string" xsi:nil="true"/>
      <ownerCode xsi:type="soapenc:string" xsi:nil="true"/>
      <processTime xsi:type="xsd:dateTime" xsi:nil="true"/>
      <projectCode xsi:type="soapenc:string" xsi:nil="true"/>
      <referenceNo xsi:type="soapenc:string" xsi:nil="true"/>
      <requestNo xsi:type="soapenc:string" xsi:nil="true"/>
      <requestTime xsi:type="xsd:dateTime" xsi:nil="true"/>
      <status xsi:type="soapenc:string" xsi:nil="true"/>
      </multiRef></soapenv:Body></soapenv:Envelope>
      </soapenv:Envelope>
      这样的,而cxf不能解析


      IP属地:天津3楼2016-01-27 10:12
      回复
        我猜,你问错地方了,这种高端问题不适合在贴吧问


        IP属地:上海来自Android客户端4楼2016-01-27 10:32
        收起回复