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)
手伝って頂けますか?
ありがとう!!!マテウス