ksoap2를 사용하여 웹 서비스를 사용하는 모바일 응용 프로그램을 만들고 있습니다. ksoap2에서 soap webservice에 ComplexType의 객체를 보낼 수 없습니다.
지금까지 내가 문자열에 포함 된 웹 서비스를 통해 복잡한 객체를 보낼 수 있었다 INT는, 등등 ... 그럼 내가 네트워크를 통해 바이트 배열을 보낼 수 있었다 배가됩니다. 그리고 지금 내 문제가 온다 :매개 변수 중 하나가 바이트 배열입니다 때 네트워크를 통해 보낼 개체를 만들려고 할 때 서버에서 faultstring 얻을.
내가 접근하고 웹 서비스는 다음과 WSDL 파일이 있습니다
다음과<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://sensors.components" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax21="http://sensors.components/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://sensors.components">
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://sensors.components/xsd">
<xs:complexType name="Pic">
<xs:sequence>
<xs:element minOccurs="0" name="accuracy" type="xs:double"/>
<xs:element minOccurs="0" name="imageInByte" nillable="true" type="xs:base64Binary"/>
<xs:element minOccurs="0" name="latitude" type="xs:double"/>
<xs:element minOccurs="0" name="longitude" type="xs:double"/>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="time" type="xs:long"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:ax22="http://sensors.components/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://sensors.components">
<xs:import namespace="http://sensors.components/xsd"/>
<xs:element name="pictureWebservice">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="args0" nillable="true" type="ax21:Pic"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pictureWebserviceResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="pictureWebserviceRequest">
<wsdl:part name="parameters" element="ns:pictureWebservice"/>
</wsdl:message>
<wsdl:message name="pictureWebserviceResponse">
<wsdl:part name="parameters" element="ns:pictureWebserviceResponse"/>
</wsdl:message>
<wsdl:portType name="PictureWSPortType">
<wsdl:operation name="pictureWebservice">
<wsdl:input message="ns:pictureWebserviceRequest" wsaw:Action="urn:pictureWebservice"/>
<wsdl:output message="ns:pictureWebserviceResponse" wsaw:Action="urn:pictureWebserviceResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PictureWSSoap11Binding" type="ns:PictureWSPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="pictureWebservice">
<soap:operation soapAction="urn:pictureWebservice" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="PictureWSSoap12Binding" type="ns:PictureWSPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="pictureWebservice">
<soap12:operation soapAction="urn:pictureWebservice" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="PictureWSHttpBinding" type="ns:PictureWSPortType">
<http:binding verb="POST"/>
<wsdl:operation name="pictureWebservice">
<http:operation location="pictureWebservice"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PictureWS">
<wsdl:port name="PictureWSHttpSoap11Endpoint" binding="ns:PictureWSSoap11Binding">
<soap:address location="http://accessible-serv.lasige.di.fc.ul.pt:8181/axis2/services/PictureWS.PictureWSHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="PictureWSHttpSoap12Endpoint" binding="ns:PictureWSSoap12Binding">
<soap12:address location="http://accessible-serv.lasige.di.fc.ul.pt:8181/axis2/services/PictureWS.PictureWSHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="PictureWSHttpEndpoint" binding="ns:PictureWSHttpBinding">
<http:address location="http://accessible-serv.lasige.di.fc.ul.pt:8181/axis2/services/PictureWS.PictureWSHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
내가 보내려고 오전 객체가 될 때 : 내가 액세스하는 데 사용하고
public class Pic implements KvmSerializable{
private double latitude;
private double longitude;
private long time;
private double accuracy;
private String name;
private byte[] imageInByte;
public byte[] getImageInByte() {
return imageInByte;
}
public void setImageInByte(byte[] imageInByte) {
this.imageInByte = imageInByte;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public double getAccuracy() {
return accuracy;
}
public void setAccuracy(double accuracy) {
this.accuracy = accuracy;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
@Override
public Object getProperty(int arg0) {
switch(arg0){
case 0:
return latitude;
case 1:
return longitude;
case 2:
return time;
case 3:
return accuracy;
case 4:
return name;
case 5:
return imageInByte;
}
return null;
}
@Override
public int getPropertyCount() {
return 6;
}
@Override
public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
switch(arg0){
case 0:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "latitude";
break;
case 1:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "longitude";
break;
case 2:
arg2.type = PropertyInfo.LONG_CLASS;
arg2.name = "time";
break;
case 3:
arg2.type = Double.class;
arg2.name = "accuracy";
break;
case 4:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "name";
break;
case 5:
arg2.type = MarshalBase64.BYTE_ARRAY_CLASS;
arg2.name = "imageInBytes";
default:
break;
}
}
@Override
public void setProperty(int arg0, Object arg1) {
// TODO Auto-generated method stub
switch(arg0){
case 0:
latitude = Double.parseDouble(arg1.toString());
break;
case 1:
longitude = Double.parseDouble(arg1.toString());
break;
case 2:
time = Long.parseLong(arg1.toString());
break;
case 3:
accuracy = Double.parseDouble(arg1.toString());
break;
case 4:
name = arg1.toString();
break;
case 5:
imageInByte = (byte[])arg1;
default:
break;
}
}
값을 웹 서비스는 다음과 같습니다 = "http://sensors.components" URL = "http://accessible-serv.lasige.di.fc.ul.pt:8181/axis2/services/PictureWS?wsdl" SOA
네임 스페이스를
String NAMESPACE = "http://sensors.components/xsd";
try {
SoapObject request = new SoapObject(connection.getNAMESPACE(), connection.getMETHOD_NAME());
PropertyInfo object = new PropertyInfo();
object.setName("picture");
object.setValue(picture);
object.setType(picture.getClass());
object.setNamespace(NAMESPACE);
request.addProperty(object);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
MarshalDouble md = new MarshalDouble();
md.register(envelope);
new MarshalBase64().register(envelope);
envelope.addMapping(NAMESPACE, "Pic", new Pic().getClass());
HttpTransportSE androidHttpTransport = new HttpTransportSE(
connection.getURL());
androidHttpTransport.call(connection.getSOAP_ACTION(), envelope);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
System.out.println("response: " + response.toString());
} catch (Exception e) {
e.printStackTrace();
}
내가 시도했지만 물체를 통과하는 성공 : P의 조치는 = "http://sensors.components/pictureWebservice" 방법 이름 = "pictureWebservice"
그런 다음 내가 웹 서비스로 보내하기 위해 사용하고있는 코드는 다음과 같다 이전에 두 배로 그들을 등록하고 byte []를 전달할 수있는 나는 인수로 그 내부에 byte []가있는 복합 형을 전달할 수 없습니다.
로그 캣 오류
다음에 제시 :SoapFault - faultcode: 'soapenv:Server' faultstring: 'Exception occurred while trying to invoke service method pictureWebservice' faultactor: 'null' detail: [email protected]
12-13 22:26:51.363: W/System.err(5393): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:112)
12-13 22:26:51.363: W/System.err(5393): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137)
12-13 22:26:51.363: W/System.err(5393): at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
12-13 22:26:51.363: W/System.err(5393): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
12-13 22:26:51.363: W/System.err(5393): at memory.aid.webservices.WSClient.WSClientPictureFile(WSClient.java:92)
12-13 22:26:51.363: W/System.err(5393): at memory.aid.memoryaid.MemoryAid$1.run(MemoryAid.java:185)
12-13 22:26:51.363: W/System.err(5393): at android.os.Handler.handleCallback(Handler.java:615)
12-13 22:26:51.367: W/System.err(5393): at android.os.Handler.dispatchMessage(Handler.java:92)
12-13 22:26:51.367: W/System.err(5393): at android.os.Looper.loop(Looper.java:137)
12-13 22:26:51.367: W/System.err(5393): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-13 22:26:51.367: W/System.err(5393): at java.lang.reflect.Method.invokeNative(Native Method)
12-13 22:26:51.367: W/System.err(5393): at java.lang.reflect.Method.invoke(Method.java:511)
12-13 22:26:51.375: W/System.err(5393): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-13 22:26:51.375: W/System.err(5393): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-13 22:26:51.375: W/System.err(5393): at dalvik.system.NativeStart.main(Native Method)
누구나 어떤 아이디어, 솔루션이나 제안이있다? 대단히 감사드립니다.
편집 : 나는 문제를 말할 수있는 것과
어떻게 든 서버의 웹 서비스에서 내가 클래스 그림에 imageInByte 매개 변수를 호출 오전하는 널 것입니다. 다른 매개 변수는 null입니다. 이름, 위도, 경도, 정확도 및 시간은 모두 유효한 매개 변수입니다. imageInByte는 null입니다. 왜? pls는 당신의 WSDL에서
은 웹 서비스의 서버에 그림 imageInByte에 대한 매개 변수가 null 것입니다. 다른 매개 변수는 imageInByte 만 null입니다. 왜? 누구든지 나를 도울 수 있습니까? 지금까지는 응답이 없습니다. – JoaoFilipeClementeMartins