用axis2解析xml失败的原因分析和解决方法

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u011768325/article/details/52459577

和同事之间调接口时遇到了如下的问题,同事用的LotusScript(wsdl文件是由他那边提供的),我用的是Java,我这边通过axis2去解析该wsdl,但解析时报下面这样的错。

More than one part for message XMLMAINRequest
       at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.addQNameRefer
ence(WSDL11ToAxisServiceBuilder.java:1168)
       at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.addQNameRefer
ence(WSDL11ToAxisServiceBuilder.java:1091)

通过半天的查询,发现是由于同事提供的wsdl里有下面这段信息,


而通过axis2去解析时,message里如果含有两个part的话,是无法解析成功。


解决方案:让同事对orderid和sysstateflag这两个信息结一层分装。


修改后可用。

展开阅读全文

XML SAX解析?失败,求原因

04-13

MyDefaultHandler.javarn[code=Java]rnpackage com.wo;rnrnimport org.xml.sax.Attributes;rnimport org.xml.sax.SAXException;rnimport org.xml.sax.helpers.DefaultHandler;rnrnimport android.util.Log;rnrnpublic class MyDefaultHandler extends DefaultHandler rn String tagName = null;rn static News news = null;rn String type = null;rnrn @Overridern public void characters(char[] ch, int start, int length)rn throws SAXException rn // TODO Auto-generated method stubrnrn if (tagName != null) rn if (type != null && type.equals("News")) rn String data = new String(ch, start, length);rnrn if (tagName.equals("ID")) rn news.setId(data);rn Log.v("news id", data);rn else if (tagName.equals("TITLE")) rn news.setTitle(data);rn Log.v("news title", data);rn else if (tagName.equals("CONTENT")) rn news.setContent(data);rn Log.v("news content", data);rn else if (tagName.equals("PUBDATE")) rn news.setPubDate(data);rn Log.v("news pubdate", data);rn rnrn rn rnrn rnrn @Overridern public void endElement(String uri, String localName, String qName)rn throws SAXException rn if (qName.equals("ITEMS")) rn if (type != null && type.equals("News")) rn Log.v("news", news.toString());rn rnrn rn qName = null;rnrn rnrn @Overridern public void startElement(String uri, String localName, String qName,rn Attributes attributes) throws SAXException rnrn if (qName.equals("ITEMS")) rn type = attributes.getValue("name");rn if (type.equals("News")) rn news = new News();rn else if (type.equals("Single")) rnrn else if (type.equals("House")) rnrn else if (type.equals("Interview")) [code=Java][/code]rnrn rn rn tagName = qName;rnrn rnrnrnrn[/code]rnNews.javarn[code=Java]rnpackage com.wo;rnrnpublic class News rn public String id;rn public String title;rn public String content;rn public String pubDate;rnrn public News() rnrn rnrn @Overridern public String toString() rn return "News [id=" + id + ", title=" + title + ", content=" + contentrn + ", pubDate=" + pubDate + "]";rn rnrn /**rn * @return the idrn */rn public String getId() rn return id;rn rnrn /**rn * @param idrn * the id to setrn */rn public void setId(String id) rn this.id = id;rn rnrn /**rn * @return the titlern */rn public String getTitle() rn return title;rn rnrn /**rn * @param titlern * the title to setrn */rn public void setTitle(String title) rn this.title = title;rn rnrn /**rn * @return the contentrn */rn public String getContent() rn return content;rn rnrn /**rn * @param contentrn * the content to setrn */rn public void setContent(String content) rn this.content = content;rn rnrn /**rn * @return the pubDatern */rn public String getPubDate() rn return pubDate;rn rnrn /**rn * @param pubDatern * the pubDate to setrn */rn public void setPubDate(String pubDate) rn this.pubDate = pubDate;rn rnrnrn[/code]rnTestCursorActivity.javarn[code=Java]rnpackage com.wo;rnrnimport java.io.BufferedReader;rnimport java.io.IOException;rnimport java.io.InputStream;rnimport java.io.InputStreamReader;rnimport java.lang.reflect.Field;rnrnimport javax.xml.parsers.ParserConfigurationException;rnimport javax.xml.parsers.SAXParser;rnimport javax.xml.parsers.SAXParserFactory;rnrnimport org.apache.http.HttpResponse;rnimport org.apache.http.HttpStatus;rnimport org.apache.http.client.ClientProtocolException;rnimport org.apache.http.client.methods.HttpGet;rnimport org.apache.http.impl.client.DefaultHttpClient;rnimport org.xml.sax.InputSource;rnimport org.xml.sax.SAXException;rnrnimport android.app.Activity;rnimport android.os.Bundle;rnrnpublic class TestCursorActivity extends Activity rn /** Called when the activity is first created. */rn @Overridern public void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.main);rnrn DefaultHttpClient client = new DefaultHttpClient();rn HttpGet request = new HttpGet("http://www.10fang.com/api/data.xml");rn try rn HttpResponse response = client.execute(request);rn int code = response.getStatusLine().getStatusCode();rn if (code == HttpStatus.SC_OK) rn InputStream is = response.getEntity().getContent();rn InputStreamReader isr = new InputStreamReader(is, "utf-8");rn InputSource inputSource = new InputSource(isr);rn SAXParserFactory factory = SAXParserFactory.newInstance();rn SAXParser parser = factory.newSAXParser();rn parser.parse(inputSource, new MyDefaultHandler());rn rn catch (ClientProtocolException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (IOException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (ParserConfigurationException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (SAXException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rnrn rnrn[/code] 论坛

XML 解析失败

04-12

求高手帮我看一个XML解析失败的问题rn修改了eclipse的编码模式,不起作用,还请大神帮求解,具体报错日志如下:rnrn; SystemID: file:/D:/zhaolinqun/lis6.01/ui/operfee/txfiles/86060102__2013-06-01_2013-06-30/TXXml_9025000036463188.xml; Line#: 22; Column#: 7rnjavax.xml.transform.TransformerException: The element type "COL5" must be terminated by the matching end-tag "".rn at org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerImpl.java:739)rn at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:715)rn at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)rn at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)rn at com.sinosoft.lis.operfee.TXBBatchPrintBL.xmlTransform(TXBBatchPrintBL.java:1286)rn at com.sinosoft.lis.operfee.TXBBatchPrintBL.dealDataXQ(TXBBatchPrintBL.java:928)rn at com.sinosoft.lis.operfee.TXBBatchPrintBL.submitData(TXBBatchPrintBL.java:201)rn at com.sinosoft.lis.operfee.BatchPrintBLF.dealData(BatchPrintBLF.java:232)rn at com.sinosoft.lis.operfee.BatchPrintBLF.submitData(BatchPrintBLF.java:178)rn at org.apache.jsp.operfee.TXBatchTabPrintSave_jsp._jspService(TXBatchTabPrintSave_jsp.java:213)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:57)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)rn at java.lang.Thread.run(Thread.java:662)rnTXBBatchPrintBL szErrMsg=解析XML文件失败!rnBatchPrintBLF szErrMsg=解析XML文件失败!rnerror:dealDatarn 论坛

没有更多推荐了,返回首页