Android开发中调用Spring CXF整合发布的java WebService接口为什么抛出异常错误?
2015-10-28 18:50:39 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
警告: Interceptor for {http://service.qdexam.com/}HelloServiceImplService#{http://service.qdexam.com/}say has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"http://service.qdexam.com/", local:"name"). Expected elements are <{}name>
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:882)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:703)
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:160)
at org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:108)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:243)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:197)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:149)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:171)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:286)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:206)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"http://service.qdexam.com/", local:"name"). Expected elements are <{}name>]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.doUnmarshal(JAXBEncoderDecoder.java:843)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.access$100(JAXBEncoderDecoder.java:102)
at org.apache.cxf.jaxb.JAXBEncoderDecoder$2.run(JAXBEncoderDecoder.java:871)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:869)
... 26 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://service.qdexam.com/", local:"name"). Expected elements are <{}name>
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:254)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:249)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.childElement(Loader.java:101)
at com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.childElement(StructureLoader.java:243)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:478)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:459)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:242)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
... 32 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://service.qdexam.com/", local:"name"). Expected elements are <{}name>
... 43 more
wsdl文件是这样的:
android调用代码如下:
//WSDL文档中的命名空间 private static final String nameSpace3="http://myUseIos/"; //WSDL文档中的URL private static final String WSDL3="http://192.168.1.103:8080/qdksptCxfService/ksptService?wdsl"; //�?��调用的方法名(获得本天气预报Web Services支持的洲、国内外省份和城市信�? private static final String studentLogin="studentLogin"; public void studentLogin() { SoapObject soapObject=new SoapObject(nameSpace3,studentLogin); //request.addProperty("参数", "参数�?);调用的方法参数与参数值(根据具体�?��可�?可不选) soapObject.addProperty("usreName", "7777777776"); soapObject.addProperty("password", "7777777776"); SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet=true; envelope.setOutputSoapObject(soapObject);//envelope.bodyOut=request; //AndroidHttpTransport httpTranstation=new AndroidHttpTransport(WSDL3); HttpTransportSE httpTranstation=new HttpTransportSE(WSDL3); try { httpTranstation.call(nameSpace3+studentLogin, envelope); Object object = envelope.getResponse(); //下面对结果进行解析,结构类似json对象 System.out.println(object.toString()+"+++++++++++++++++++++++++++"); } catch (IOException e) { e.printStackTrace(); } catch (XmlPullParserException e) { e.printStackTrace(); } }
正确的android调用代码如下:
String nameSpace3="http://myUseIos/"; String WSDL3="http://192.168.1.103:8080/qdksptCxfService/ksptService"; String studentLogin="studentLogin"; String listPapers = "listPapers"; String listPapersCurrent = "listPapersCurrent"; // 登录 public void studentLogin() { HttpTransportSE httpTranstation=new HttpTransportSE(WSDL3); SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11); SoapObject request =new SoapObject(nameSpace3,studentLogin); String userName = "7777777777"; String password = "7777777777"; request.addProperty("userName", userName); request.addProperty("password", password); envelope.setOutputSoapObject(request); try { httpTranstation.call(null, envelope); Object object = envelope.getResponse(); System.out.println("object" + object); } catch (IOException e) { e.printStackTrace(); } catch (XmlPullParserException e) { e.printStackTrace(); } } }
- 等 最代码怎么获取牛币啊?
- 完 谁来告诉我最代码上线的时间,答对者给5牛币,先来先得
- 等 牛友们,大家好,你们做程序员多久了?现在还好吗?
- 完 在微信打开的页面里进行app下载
- 等 最代码2014年欢乐聚声会
- 完 mysql如何查询表数据并且对3个字段降序的SQL?
- 完 最代码牛币机制改革
- 完 成功的在bae上使用了自定义运行环境 jetty+nginx的组合,大家对jetty+nginx优化有哪些心得?
- 完 进来分享一下各位牛牛是如何加入最代码大家庭的?
- 等 为什么java BufferedImage类处理大图直接抛出内存溢出的异常?
- 等 最代码是否开发手机app客户端?
- 完 java程序员学习哪些java的技术?java有哪些框架?都能做哪方面的开发?
- 等 php格式网页文件怎么运行?
- 等 Java volatile值获取的问题
- 等 前端vue,拦截了登录后台后,返回的token,requests拦截token,但是发送请求的时候,就出现跨越异常
- 等 大专本科计算机科班怎么找到Java工作?
- 等 eclipse怎么把三个java swing游戏项目合成一个项目?
- 完 伙伴们,大家都有什么好的解压方式么,分享一下~
- 完 三四线城市,6、7k,运维工作,索然无味,想去辞职上培训,各位牛牛有什么建议嘛
- 等 jsp页面输入中文变成问号
- 等 JPA在线上运行一段时间后报错Caused by: java.lang.IncompatibleClassChangeError: null
- 等 PHP 这个规则用preg_match_all怎么写
- 等 大佬们,有没有知道Alfresco如何配置LDAP登录呢?
- 等 php的install目录是框架带的吗?
- 等 webservice问题求解决,急急急
- 完 可否有人简单口述一下什么是webService接口?
- 完 weblogic服务器中调用其他系统中的webservice接口,报权限问题
- 等 如何在html静态网页调用axis2 webservice接口?
- 完 如何在java Web项目中开发WebService接口
- 完 java webservice如何连接访问数据库
- 完 Java如何发布WebService接口供客户端调用
- 完 java webservice参数与返回值不固定的方法如何发布?
- 等 java调用webservice接口出错怎么解决?
- 完 java调用WebService接口为什么这么慢?和数据库或发布WebService的方式有关系吗?
- 完 手持仪WebService异常信息记录数据库是否合理?
- 等 .net调用java端发布的webservice返回值类型问题