Can';t将ComplexType对象从ksoap2 for android发送到soap Web服务

Can';t将ComplexType对象从ksoap2 for android发送到soap Web服务,android,web-services,soap,wsdl,ksoap2,Android,Web Services,Soap,Wsdl,Ksoap2,我正在做一个移动应用程序,通过使用ksoap2使用web服务 到目前为止,我能够通过包含字符串、double、int等的Web服务发送复杂对象 然后我就可以通过网络发送字节数组了。现在我的问题来了: 当我试图创建一个对象通过网络发送时,当其中一个参数是字节数组时,我从服务器获得一个faultstring 我正在访问的web服务具有以下wsdl文件: <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:n

我正在做一个移动应用程序,通过使用ksoap2使用web服务

到目前为止,我能够通过包含字符串、double、int等的Web服务发送复杂对象

然后我就可以通过网络发送字节数组了。现在我的问题来了:

当我试图创建一个对象通过网络发送时,当其中一个参数是字节数组时,我从服务器获得一个faultstring

我正在访问的web服务具有以下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>
我用于访问web服务的值如下:

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();
        }
namespace=“” url=“” soap action=“” 方法名称=“pictureWebservice”

然后,我将使用以下代码将其发送到Web服务:

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();
        }
尽管我曾经尝试并成功地通过double传递对象,并注册它们,并且能够传递byte[],但我无法传递一个复杂类型,其中包含byte[]作为参数

logcat错误如下所示:

SoapFault - faultcode: 'soapenv:Server' faultstring: 'Exception occurred while trying to invoke service method pictureWebservice' faultactor: 'null' detail: org.kxml2.kdom.Node@4153d588
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)
有人有什么想法、解决方案或建议吗?事先非常感谢

编辑:

从我所能看出的问题是,在服务器的Web服务中,我调用类Pic中的imageInByte参数为null。没有其他参数为null。名称、纬度、经度、精度和时间都是有效参数,byt imageInByte为空。为什么?请帮助

在您的wsdl中,您已经将这个字段“imageInByte”定义为简单类型,这就是为什么它会给您这个错误

将其定义为复杂类型,包含您试图传递的所有字段

谢谢,
ambuj

发生的情况是,在web服务的服务器中,Pic imageInByte的参数为空。没有其他参数仅为null imageInByte。为什么?有人能帮我吗?目前没有回应。