1

我正在为 Web 服务开发客户端(代理)(测试调用轴 Web 服务)。XSD 是:

    <complexType name="getPermissionsRequest">
    <sequence>
        <element name="idEmploye" type="string"></element>
    </sequence>
</complexType>

<complexType name="getPermissionsResponse">
    <sequence>
        <element name="permissions" type="tns:permission" maxOccurs="unbounded" minOccurs="0"></element>
    </sequence>
</complexType>

<complexType name="permission">
    <sequence>
        <element name="idEmploye" type="string"></element>
        <element name="idSystem" type="string"></element>           
    </sequence>
</complexType>

<element name="GetPermissionsRequest"
    type="tns:getPermissionsRequest">
</element>

<element name="GetPermissionsResponse"
    type="tns:getPermissionsResponse">
</element>

根据请求添加复杂类型的代码部分是:

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);    

GetPermissionsRequest p = new GetPermissionsRequest();
p.setIdEmploye("1");        
request.addProperty("getPermissionsRequest", p);        

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;    
envelope.addMapping(NAMESPACE, "GetPermissionsRequest", p.getClass());
envelope.setOutputSoapObject(request);      

HttpTransportSE ht = new HttpTransportSE(URL);
ht.debug = true;
try {
    ht.call(SOAP_ACTION + METHOD_NAME, envelope);
} catch (IOException e) {
    e.printStackTrace();
} catch (XmlPullParserException e) {
    e.printStackTrace();
}

我的对象实现了 KvmSerializable:

import java.util.Hashtable;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;

public class GetPermissionsRequest implements KvmSerializable {

    private String idEmploye;    

    public GetPermissionsRequest() {}

    public GetPermissionsRequest(String id) {
        this.idEmploye = id;        
    }

    public void setIdEmploye(String id) { this.idEmploye = id; }    
    public String getIdEmploye() { return this.idEmploye;}

    public Object getProperty(int arg0) {
        switch(arg0) {
            case 0:
                return idEmploye;
        }
        return null;
    }

    public int getPropertyCount() {
        return 1;
    }

    public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo propertyInfo) {
        switch(index){
        case 0:
            propertyInfo.name = "idEmploye";
            propertyInfo.type = PropertyInfo.STRING_CLASS;
            break;        
        default:
            break;
        }
    }

    public void setProperty(int index, Object value) {
        switch(index) {
            case 0:
                this.idEmploye = value.toString();
                break;        
            default:
                break;
        }
    }    
}

但是,运行时,异常:

java.io.IOException: BufferedInputStream is closed
at java.io.BufferedInputStream.streamClosed(BufferedInputStream.java:116)
at java.io.BufferedInputStream.read(BufferedInputStream.java:294)
GC_CONCURRENT freed 326K, 51% free 2817K/5703K, external 201K/659K, paused 1ms+1ms
at org.ksoap2.transport.HttpTransportSE.readDebug(HttpTransportSE.java:273)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:241)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:111)

你能帮助我吗?

谢谢!!!马特乌斯

4

0 回答 0