gpt4 book ai didi

android - 使用 kSOAP 发送自定义对象

转载 作者:行者123 更新时间:2023-11-29 22:02:30 28 4
gpt4 key购买 nike

我正在使用 ksoap2 (ksoap2-android-assembly-3.0.0-RC.1-jar-with-dependencies.jar) 与我的 android 应用通信在 jboss 7 (jboss-as-7.1.1_Final & jbossws-cxf-4.0.2.GA) 和 jaxws-2.2.6-2 上设置的 soap 服务-20120518。

我能够获取任何数据(任何意味着我的自定义对象)但我无法发送它们。我关注了this文章。我的对象(名为“Frame”)正在实现 org.ksoap2.serialization.KvmSerializable。

我的请求包装器类如下所示:

@XmlRootElement(name = "addFrame", namespace = "http://frame.service.server.android.i2.eu/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "addFrame", namespace = "http://frame.service.server.android.i2.eu/")
public class AddFrame {

@XmlElement(name = "arg0")
private Frame frame;

public Frame getFrame() {
return frame;
}

public void setFrame(Frame frame) {
this.frame = frame;
}
}

当我尝试使用 java se 方法 (javax.xml.namespace.QName & javax.xml.ws.Service) 发送对象(不在 android 内部)时,对象保存在我的 mssql 数据库中,所以我认为存在一些问题使用我的 android 客户端实现。

String namespace = "http://frame.service.server.android.i2.eu/";
String wsdl = "http://localhost:8080/AndroidServer/AndreyServices/FrameService?wsdl";
String action = "addFrame";
String method = "http://frame.service.server.android.i2.eu/addFrame";

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

SoapObject request = new SoapObject(namespace, action)

PropertyInfo info = new PropertyInfo();
info.setType(Frame.class);
info.setValue(frame);//frame as a java method parameter
info.setName("arg0");
request.addProperty(info);

envelope.setOutputSoapObject(request);

HttpTransportSE soapCall = new HttpTransportSE(wsdl);
soapCall.call(action, envelope);

在此之后我收到:

  • 安卓日志:
07-22 16:48:51.256: E/FRAME(1013): eu.i2.android.delegate.exception.DelegateException: SoapFault - faultcode: 'soap:Client' faultstring: 'Unmarshalling Error: null ' faultactor: 'null' detail: null07-22 16:48:51.256: E/FRAME(1013): eu.i2.android.interfaces.exceptions.CommunicationException: eu.i2.android.delegate.exception.DelegateException: SoapFault - faultcode: 'soap:Client' faultstring: 'Unmarshalling Error: null ' faultactor: 'null' detail: null07-22 16:48:51.256: E/FRAME(1013):  at eu.i2.android.communication.Communication.addFrame(Communication.java:81)07-22 16:48:51.256: E/FRAME(1013):  at eu.u2.android.client.Client.onCreate(Client.java:54)07-22 16:48:51.256: E/FRAME(1013):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)07-22 16:48:51.256: E/FRAME(1013):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)07-22 16:48:51.256: E/FRAME(1013):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)07-22 16:48:51.256: E/FRAME(1013):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)07-22 16:48:51.256: E/FRAME(1013):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)07-22 16:48:51.256: E/FRAME(1013):  at android.os.Handler.dispatchMessage(Handler.java:99)07-22 16:48:51.256: E/FRAME(1013):  at android.os.Looper.loop(Looper.java:123)07-22 16:48:51.256: E/FRAME(1013):  at android.app.ActivityThread.main(ActivityThread.java:4627)07-22 16:48:51.256: E/FRAME(1013):  at java.lang.reflect.Method.invokeNative(Native Method)07-22 16:48:51.256: E/FRAME(1013):  at java.lang.reflect.Method.invoke(Method.java:521)07-22 16:48:51.256: E/FRAME(1013):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)07-22 16:48:51.256: E/FRAME(1013):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)07-22 16:48:51.256: E/FRAME(1013):  at dalvik.system.NativeStart.main(Native Method)07-22 16:48:51.256: E/FRAME(1013): Caused by: eu.i2.android.delegate.exception.DelegateException: SoapFault - faultcode: 'soap:Client' faultstring: 'Unmarshalling Error: null ' faultactor: 'null' detail: null07-22 16:48:51.256: E/FRAME(1013):  at eu.i2.android.delegate.delegates.FrameDelegate.addFrame(FrameDelegate.java:152)07-22 16:48:51.256: E/FRAME(1013):  at eu.i2.android.communication.Communication.addFrame(Communication.java:79)07-22 16:48:51.256: E/FRAME(1013):  ... 14 more07-22 16:48:51.256: E/FRAME(1013): Caused by: SoapFault - faultcode: 'soap:Client' faultstring: 'Unmarshalling Error: null ' faultactor: 'null' detail: null07-22 16:48:51.256: E/FRAME(1013):  at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:141)07-22 16:48:51.256: E/FRAME(1013):  at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)07-22 16:48:51.256: E/FRAME(1013):  at org.ksoap2.transport.Transport.parseResponse(Transport.java:116)07-22 16:48:51.256: E/FRAME(1013):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:235)07-22 16:48:51.256: E/FRAME(1013):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)07-22 16:48:51.256: E/FRAME(1013):  at eu.i2.android.delegate.AbstractDelegate$SoapCall.call(AbstractDelegate.java:219)07-22 16:48:51.256: E/FRAME(1013):  at eu.i2.android.delegate.delegates.FrameDelegate.addFrame(FrameDelegate.java:141)07-22 16:48:51.256: E/FRAME(1013):  ... 15 more
  • 服务器日志:
18:48:52,057 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http-localhost-127.0.0.1-8080-2) Interceptor for {http://frame.service.server.android.i2.eu/}AndreyServices#{http://frame.service.server.android.i2.eu/}addFrame has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: Unmarshalling Error: null     at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:808)    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:642)    at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156)    at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109)    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207)    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:91)    at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:169)    at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87)    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185)    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:108)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]    at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135)    at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140) [jbossws-spi.jar:2.0.3.GA]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_33]Caused by: java.lang.NullPointerException    at org.apache.cxf.jaxb.io.DataReaderImpl$WSUIDValidationHandler.handleEvent(DataReaderImpl.java:69)    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:655)    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:691)    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:687)    at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.handleParseConversionException(Loader.java:271)    at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:69)    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:514)    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.processText(StAXStreamConnector.java:339)    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleEndElement(StAXStreamConnector.java:217)    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:186)    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:369)    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:348)    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:778)    ... 29 more

我没有安装来自 here 的任何 jar在 jboss 模块中。

提前致谢!

最佳答案

android 客户端中的 null 在类中缺少 SoapObjects 扩展,我建议在 android 上也使用 CXF 客户端,因为它会自动生成类。

http://code.google.com/p/android-ws-client/

关于android - 使用 kSOAP 发送自定义对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11602318/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com