Android的Ksoap2 - 复杂类型(请求和响应) [英] Android Ksoap2 - complex type(request and response)

查看:152
本文介绍了Android的Ksoap2 - 复杂类型(请求和响应)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用kso​​ap2调用Android中java的Web服务。
Java的Web服务的方法是,

ImageProcessImpl.java

 公共UserResponse样品(UserRequest userRequest){
     返回ImageProcessDAO.sample(userRequest);
}

ImageProcessDAO.java

 公共静态字符串样品(UserRequest userRequest){
     的System.out.println(userRequest.getClientName());
     UserResponse UserResponse =新UserResponse();
     userResponse.setMessage(成功);
     返回userResponse;
}

我是从Android的调用这些Web服务的,

  {尝试
        字符串NAMESPACE =htt​​p://impl.test.com;
        字符串的URL =htt​​p://10.0.2.2:8080/Webservice/services/ImageProcessImpl?wsdl;
        字符串SOAP_ACTION =htt​​p://impl.test.com/sample;
        字符串METHOD_NAME =样本;        SoapObject要求=新SoapObject空间(namespace,METHOD_NAME);        UserRequest userRequest =新UserRequest();
        userRequest.setClientName(测试);        PI的PropertyInfo =新的PropertyInfo();
        pi.setName(userRequest);
        pi.setValue(userRequest);
        pi.setType(UserRequest.class);
        request.addProperty(PI);        SoapSerializationEnvelope信封=新SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(请求);
        envelope.implicitTypes = TRUE;
        envelope.addMapping(命名空间UserResponse,UserResponse.class);        AndroidHttpTransport httpTransport =新AndroidHttpTransport(URL);
        httpTransport.debug = TRUE;
        httpTransport.call(SOAP_ACTION,信封);       UserResponse响应=(UserResponse)envelope.getResponse();
       Log.e(Test.LOG_TAG,response.getMessage());
        }赶上(例外五){
            Log.e(Test.LOG_TAG抛出一个异常:+ e.getMessage());
        }

但我在我的LogCat中得到的错误是抛出异常:无法序列:com.test.common.UserRequest 。如何解决这个问题?这是调用Web服务复杂类型正确的方式?

我的WSDL文件,

 <?XML版本=1.0编码=UTF-8&GT?;
< WSDL:定义的targetNamespace =htt​​p://impl.test.com的xmlns:ApacheSOAP中=htt​​p://xml.apache.org/xml-soap的xmlns:IMPL =HTTP://impl.test。 COM的xmlns:INTF =http://impl.test.com的xmlns:tns1 =http://common.test.com的xmlns:WSDL =http://schemas.xmlsoap.org/wsdl/的xmlns:的wsdlsoap =htt​​p://schemas.xmlsoap.org/wsdl/soap/的xmlns:XSD =htt​​p://www.w3.org/2001/XMLSchema>
!< - 通过Apache Axis的版本创建的WSDL:1.4
建于2006年4月22日(6点55分48秒PDT) - GT;
 < WSDL:类型>
  <架构将elementFormDefault =合格的targetNamespace =htt​​p://impl.test.com的xmlns =htt​​p://www.w3.org/2001/XMLSchema>
   <进口命名空间=htt​​p://common.test.com/>
   <元素名称=样品>
    <&复杂类型GT;
     <序列>
      <元素名称=userRequestTYPE =tns1:UserRequest/>
     < /序列>
    < /复杂类型>
   < /组件>
   <元素名称=sampleResponse>
    <&复杂类型GT;
     <序列>
      <元素名称=sampleReturnTYPE =tns1:UserResponse/>
     < /序列>
    < /复杂类型>
   < /组件>
  < /模式>
  <架构将elementFormDefault =合格的targetNamespace =htt​​p://common.test.com的xmlns =htt​​p://www.w3.org/2001/XMLSchema>
   <复杂类型名称=UserRequest>
    <序列>
     <元素名称=CLIENTNAME的nillable =真TYPE =XSD:字符串/>
    < /序列>
   < /复杂类型>
   <复杂类型名称=UserResponse>
    <序列>
     <元素名称=消息的nillable =真TYPE =XSD:字符串/>
    < /序列>
   < /复杂类型>
  < /模式>
 < / WSDL:类型>   < WSDL:消息名称=sampleRequest>      < WSDL:部分元素=IMPL:样本NAME =参数>      < / WSDL:部分>   < / WSDL:消息>   < WSDL:消息名称=sampleResponse>      < WSDL:部分元素=IMPL:sampleResponseNAME =参数>      < / WSDL:部分>   < / WSDL:消息>   < WSDL:portType的名称=ImageProcessImpl>      < WSDL:操作名称=样品>         < WSDL:输入消息=IMPL:sampleRequestNAME =sampleRequest>       < / WSDL:输入>         < WSDL:输出消息=IMPL:sampleResponseNAME =sampleResponse>       < / WSDL:输出>      < / WSDL:运转>   < / WSDL:portType的>   < WSDL:绑定名称=ImageProcessImplSoapBindingTYPE =IMPL:ImageProcessImpl>      <的wsdlsoap:绑定样式=文件传输=htt​​p://schemas.xmlsoap.org/soap/http/>
      < WSDL:操作名称=样品>         <的wsdlsoap:操作的soapAction =/>         < WSDL:输入名称=sampleRequest>            <的wsdlsoap:身体使用=文字/>         < / WSDL:输入>         < WSDL:输出名称=sampleResponse>            <的wsdlsoap:身体使用=文字/>         < / WSDL:输出>      < / WSDL:运转>   < / WSDL:结合>   < WSDL:服务名称=ImageProcessImplService>      < WSDL:端口绑定=IMPL:ImageProcessImplSoapBindingNAME =ImageProcessImpl>         <的wsdlsoap:地址位置=HTTP://本地主机:8080 / web服务/服务/ ImageProcessImpl/>      < / WSDL:端口>   < / WSDL:服务>< / WSDL:定义>

我用KvmSerializable。我已经增加了一个数组变量豆
私人客户[] clientNameList = NULL; 在UserRequest.java。

当我调用Web服务,它正在请求罚款。但在回应我得到一个包含所有值的一个字符串。响应字符串给出以下

{anyType的= clientNameList {anyType的= clientNameList {anyType的clientID的= 1; }; clientNameList = {anyType的clientID的= 2; }; };消息=成功; }

我如何解析这个字符串?

UserResponse.java

 公共类UserResponse实现KvmSerializable {公共字符串消息= NULL;
公共客户端[] clientNameList = NULL;@覆盖
公共对象的getProperty(INT指数){
    开关(指数){
    情况下0:
        返回消息;
    情况1:
        返回clientNameList;
     默认:
         返回null;
    }
}@覆盖
公众诠释getPropertyCount(){
    // TODO自动生成方法存根
    返回2;
}@覆盖
公共无效为getPropertyInfo(INT指数,Hashtable的ARG1,信息的PropertyInfo){
    开关(指数)
    {
    情况下0:
        info.type = PropertyInfo.STRING_CLASS;
        info.name =消息;
        打破;
    情况1:
        info.type = PropertyInfo.OBJECT_TYPE;
        info.name =clientNameList;
        打破;
    默认:
        打破;
    }}@覆盖
公共无效的setProperty(INT指数,对象的值){
    开关(指数)
    {
    情况下0:
        消息= value.toString();
        打破;
    情况1:
        clientNameList =(客户端[])值;
        打破;
    默认:
        打破;
    }}
}

Client.java包含整数类型的唯一的clientId。

更新code和WSDL

ImageProcessImpl.java

 公共UserResponse样品(UserRequest userRequest){
     返回ImageProcessDAO.sample(userRequest);
}

ImageProcessDAO.java

 公共静态字符串样品(UserRequest userRequest){
    的System.out.println(userRequest.getClientName());
    UserResponse userResponse =新UserResponse();
    userResponse.setMessage(SUCCESS);
    客户端[] =客户端新[2];
    Client客户端= NULL;
    的for(int i = 0;我2;我++)
    {
        客户=新客户();
        client.setClientID第(i + 1);
        客户端[I] =客户端;
    }
    userResponse.setClientNameList(客户机);
    返回userResponse;
}

我是从Android的调用这些Web服务的,

  {尝试
        字符串NAMESPACE =htt​​p://impl.test.com;
        字符串的URL =htt​​p://10.0.2.2:8080/Webservice/services/ImageProcessImpl?wsdl;
        字符串SOAP_ACTION =htt​​p://impl.test.com/sample;
        字符串METHOD_NAME =样本;        SoapObject要求=新SoapObject空间(namespace,METHOD_NAME);        UserRequest userRequest =新UserRequest();
        userRequest.setClientName(测试);        PI的PropertyInfo =新的PropertyInfo();
        pi.setName(userRequest);
        pi.setValue(userRequest);
        pi.setType(UserRequest.class);
        request.addProperty(PI);        SoapSerializationEnvelope信封=新SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(请求);
        envelope.implicitTypes = TRUE;
        envelope.addMapping(命名空间userRequest,UserRequest.class);
        envelope.addMapping(命名空间UserResponse,UserResponse.class);        AndroidHttpTransport httpTransport =新AndroidHttpTransport(URL);
        httpTransport.debug = TRUE;
        httpTransport.call(SOAP_ACTION,信封);       SoapObject结果=(SoapObject)envelope.getResponse();
       userResponse.message = result.getProperty(0)的ToString();
       Log.e(Test.LOG_TAG,userResponse.message);
        }赶上(例外五){
            Log.e(Test.LOG_TAG抛出一个异常:+ e.getMessage());
        }

我的新的WSDL文件,

 <?XML版本=1.0编码=UTF-8&GT?;
< WSDL:定义的targetNamespace =htt​​p://impl.test.com的xmlns:ApacheSOAP中=htt​​p://xml.apache.org/xml-soap的xmlns:IMPL =HTTP://impl.test。 COM的xmlns:INTF =http://impl.test.com的xmlns:tns1 =http://common.test.com的xmlns:WSDL =http://schemas.xmlsoap.org/wsdl/的xmlns:的wsdlsoap =htt​​p://schemas.xmlsoap.org/wsdl/soap/的xmlns:XSD =htt​​p://www.w3.org/2001/XMLSchema>
!< - 通过Apache Axis的版本创建的WSDL:1.4
建于2006年4月22日(6点55分48秒PDT) - GT;
 < WSDL:类型>
  <架构将elementFormDefault =合格的targetNamespace =htt​​p://impl.test.com的xmlns =htt​​p://www.w3.org/2001/XMLSchema>
   <进口命名空间=htt​​p://common.test.com/>
   <元素名称=样品>
    <&复杂类型GT;
     <序列>
      <元素名称=userRequestTYPE =tns1:UserRequest/>
     < /序列>
    < /复杂类型>
   < /组件>
   <元素名称=sampleResponse>
    <&复杂类型GT;
     <序列>
      <元素名称=sampleReturnTYPE =tns1:UserResponse/>
     < /序列>
    < /复杂类型>
   < /组件>
   <复杂类型名称=ArrayOf_tns1_Client>
    <序列>
     <元素的maxOccurs =无界的minOccurs =0NA​​ME =项TYPE =tns1:客户端/>
    < /序列>
   < /复杂类型>
  < /模式>
  <架构将elementFormDefault =合格的targetNamespace =htt​​p://common.test.com的xmlns =htt​​p://www.w3.org/2001/XMLSchema>
   <进口命名空间=htt​​p://impl.test.com/>
   <复杂类型名称=UserRequest>
    <序列>
     <元素名称=CLIENTNAME的nillable =真TYPE =XSD:字符串/>
    < /序列>
   < /复杂类型>
   <复杂类型名称=客户端>
    <序列>
     <元素名称=clientID的TYPE =XSD:INT/>
    < /序列>
   < /复杂类型>
   <复杂类型名称=UserResponse>
    <序列>
     <元素名称=clientNameList的nillable =真TYPE =IMPL:ArrayOf_tns1_Client/>
     <元素名称=消息的nillable =真TYPE =XSD:字符串/>
    < /序列>
   < /复杂类型>
  < /模式>
 < / WSDL:类型>   < WSDL:消息名称=sampleRequest>      < WSDL:部分元素=IMPL:样本NAME =参数>      < / WSDL:部分>   < / WSDL:消息>   < WSDL:消息名称=sampleResponse>      < WSDL:部分元素=IMPL:sampleResponseNAME =参数>      < / WSDL:部分>   < / WSDL:消息>   < WSDL:portType的名称=ImageProcessImpl>      < WSDL:操作名称=样品>         < WSDL:输入消息=IMPL:sampleRequestNAME =sampleRequest>       < / WSDL:输入>         < WSDL:输出消息=IMPL:sampleResponseNAME =sampleResponse>       < / WSDL:输出>      < / WSDL:运转>   < / WSDL:portType的>   < WSDL:绑定名称=ImageProcessImplSoapBindingTYPE =IMPL:ImageProcessImpl>      <的wsdlsoap:绑定样式=文件传输=htt​​p://schemas.xmlsoap.org/soap/http/>      < WSDL:操作名称=样品>         <的wsdlsoap:操作的soapAction =/>         < WSDL:输入名称=sampleRequest>            <的wsdlsoap:身体使用=文字/>         < / WSDL:输入>         < WSDL:输出名称=sampleResponse>            <的wsdlsoap:身体使用=文字/>         < / WSDL:输出>      < / WSDL:运转>   < / WSDL:结合>   < WSDL:服务名称=ImageProcessImplService>      < WSDL:端口绑定=IMPL:ImageProcessImplSoapBindingNAME =ImageProcessImpl>         <的wsdlsoap:地址位置=HTTP://本地主机:8080 / web服务/服务/ ImageProcessImpl/>      < / WSDL:端口>   < / WSDL:服务>< / WSDL:定义>


解决方案

您UserRequest类需要实现org.ksoap2.serialization.KvmSerializable。

I am using ksoap2 to call the java webservice in Android. Java Web service method is,

ImageProcessImpl.java

public UserResponse sample(UserRequest userRequest) {
     return ImageProcessDAO.sample(userRequest);
}

ImageProcessDAO.java

public static String sample(UserRequest userRequest) {
     System.out.println(userRequest.getClientName());
     UserResponse UserResponse = new UserResponse();
     userResponse.setMessage("SUCCESS");
     return userResponse;
}

I am calling these webservices from Android as,

try{
        String NAMESPACE = "http://impl.test.com";
        String URL = "http://10.0.2.2:8080/Webservice/services/ImageProcessImpl?wsdl";  
        String SOAP_ACTION = "http://impl.test.com/sample";
        String METHOD_NAME = "sample";

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

        UserRequest userRequest = new UserRequest();            
        userRequest.setClientName("Test");

        PropertyInfo pi = new PropertyInfo();
        pi.setName("userRequest");
        pi.setValue(userRequest);
        pi.setType(UserRequest.class);
        request.addProperty(pi);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
        envelope.setOutputSoapObject(request);  
        envelope.implicitTypes = true;
        envelope.addMapping(NAMESPACE, "UserResponse", UserResponse.class);

        AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);  
        httpTransport.debug = true;
        httpTransport.call(SOAP_ACTION, envelope);

       UserResponse response = (UserResponse) envelope.getResponse(); 
       Log.e(Test.LOG_TAG, response.getMessage());
        }catch (Exception e) {
            Log.e(Test.LOG_TAG, "throws an exception: " + e.getMessage());
        }

But I am getting the error in my Logcat is "throws an exception: Cannot serialize: com.test.common.UserRequest". How to fix this error? Is this right way to call web service with complex type?

my wsdl file is,

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://impl.test.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://impl.test.com" xmlns:intf="http://impl.test.com" xmlns:tns1="http://common.test.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://impl.test.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://common.test.com"/>
   <element name="sample">
    <complexType>
     <sequence>
      <element name="userRequest" type="tns1:UserRequest"/>
     </sequence>
    </complexType>
   </element>
   <element name="sampleResponse">
    <complexType>
     <sequence>
      <element name="sampleReturn" type="tns1:UserResponse"/>
     </sequence>
    </complexType>
   </element>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="http://common.test.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <complexType name="UserRequest">
    <sequence>
     <element name="clientName" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
   <complexType name="UserResponse">
    <sequence>
     <element name="message" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
  </schema>
 </wsdl:types>

   <wsdl:message name="sampleRequest">

      <wsdl:part element="impl:sample" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="sampleResponse">

      <wsdl:part element="impl:sampleResponse" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:portType name="ImageProcessImpl">

      <wsdl:operation name="sample">

         <wsdl:input message="impl:sampleRequest" name="sampleRequest">

       </wsdl:input>

         <wsdl:output message="impl:sampleResponse" name="sampleResponse">

       </wsdl:output>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="ImageProcessImplSoapBinding" type="impl:ImageProcessImpl">

      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="sample">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="sampleRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="sampleResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="ImageProcessImplService">

      <wsdl:port binding="impl:ImageProcessImplSoapBinding" name="ImageProcessImpl">

         <wsdlsoap:address location="http://localhost:8080/Webservice/services/ImageProcessImpl"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

I used the KvmSerializable. I have added one more array bean variable private Client[] clientNameList = null; in UserRequest.java.

When I call the web service it is working fine in the request. But in the response I am getting one string that contains all values. The response string is given below.

anyType{clientNameList=anyType{clientNameList=anyType{clientID=1; }; clientNameList=anyType{clientID=2; }; }; message=SUCCESS; }.

How Can I parse this string?

UserResponse.java

public class UserResponse implements KvmSerializable{

public String message = null;
public Client[] clientNameList = null;

@Override
public Object getProperty(int index) {
    switch (index){
    case 0:
        return message;
    case 1:
        return clientNameList;
     default:
         return null;
    }
}

@Override
public int getPropertyCount() {
    // TODO Auto-generated method stub
    return 2;
}

@Override
public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
    switch(index)
    {
    case 0:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "message";
        break;
    case 1:
        info.type = PropertyInfo.OBJECT_TYPE;
        info.name = "clientNameList";
        break;
    default:
        break;
    }

}

@Override
public void setProperty(int index, Object value) {
    switch(index)
    {
    case 0:
        message = value.toString();
        break;
    case 1:
        clientNameList = (Client[]) value;
        break;
    default:
        break;
    }

}   
}

Client.java contains only clientId of Integer type.

Updated code and wsdl

ImageProcessImpl.java

public UserResponse sample(UserRequest userRequest) {
     return ImageProcessDAO.sample(userRequest);
}

ImageProcessDAO.java

public static String sample(UserRequest userRequest) {
    System.out.println(userRequest.getClientName());
    UserResponse userResponse = new UserResponse();
    userResponse.setMessage(SUCCESS);
    Client[] clients = new Client[2];
    Client client = null;
    for(int i=0;i<2;i++)
    {
        client = new Client();
        client.setClientID(i+1);
        clients[i] = client;
    }
    userResponse.setClientNameList(clients);
    return userResponse;
}

I am calling these webservices from Android as,

try{
        String NAMESPACE = "http://impl.test.com";
        String URL = "http://10.0.2.2:8080/Webservice/services/ImageProcessImpl?wsdl";  
        String SOAP_ACTION = "http://impl.test.com/sample";
        String METHOD_NAME = "sample";

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

        UserRequest userRequest = new UserRequest();            
        userRequest.setClientName("Test");

        PropertyInfo pi = new PropertyInfo();
        pi.setName("userRequest");
        pi.setValue(userRequest);
        pi.setType(UserRequest.class);
        request.addProperty(pi);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
        envelope.setOutputSoapObject(request);  
        envelope.implicitTypes = true;
        envelope.addMapping(NAMESPACE, "userRequest", UserRequest.class);
        envelope.addMapping(NAMESPACE, "UserResponse", UserResponse.class);

        AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);  
        httpTransport.debug = true;
        httpTransport.call(SOAP_ACTION, envelope);

       SoapObject result = (SoapObject) envelope.getResponse();
       userResponse.message = result.getProperty(0).toString();
       Log.e(Test.LOG_TAG, userResponse.message);
        }catch (Exception e) {
            Log.e(Test.LOG_TAG, "throws an exception: " + e.getMessage());
        }

my new wsdl file is,

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://impl.test.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://impl.test.com" xmlns:intf="http://impl.test.com" xmlns:tns1="http://common.test.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://impl.test.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://common.test.com"/>
   <element name="sample">
    <complexType>
     <sequence>
      <element name="userRequest" type="tns1:UserRequest"/>
     </sequence>
    </complexType>
   </element>
   <element name="sampleResponse">
    <complexType>
     <sequence>
      <element name="sampleReturn" type="tns1:UserResponse"/>
     </sequence>
    </complexType>
   </element>
   <complexType name="ArrayOf_tns1_Client">
    <sequence>
     <element maxOccurs="unbounded" minOccurs="0" name="item" type="tns1:Client"/>
    </sequence>
   </complexType>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="http://common.test.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://impl.test.com"/>
   <complexType name="UserRequest">
    <sequence>
     <element name="clientName" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
   <complexType name="Client">
    <sequence>
     <element name="clientID" type="xsd:int"/>
    </sequence>
   </complexType>
   <complexType name="UserResponse">
    <sequence>
     <element name="clientNameList" nillable="true" type="impl:ArrayOf_tns1_Client"/>
     <element name="message" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
  </schema>
 </wsdl:types>

   <wsdl:message name="sampleRequest">

      <wsdl:part element="impl:sample" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="sampleResponse">

      <wsdl:part element="impl:sampleResponse" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:portType name="ImageProcessImpl">

      <wsdl:operation name="sample">

         <wsdl:input message="impl:sampleRequest" name="sampleRequest">

       </wsdl:input>

         <wsdl:output message="impl:sampleResponse" name="sampleResponse">

       </wsdl:output>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="ImageProcessImplSoapBinding" type="impl:ImageProcessImpl">

      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="sample">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="sampleRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="sampleResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="ImageProcessImplService">

      <wsdl:port binding="impl:ImageProcessImplSoapBinding" name="ImageProcessImpl">

         <wsdlsoap:address location="http://localhost:8080/Webservice/services/ImageProcessImpl"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

解决方案

Your UserRequest class needs to implement org.ksoap2.serialization.KvmSerializable.

这篇关于Android的Ksoap2 - 复杂类型(请求和响应)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆