java调用webservice payload方式,求大佬哪个大佬看看

java调用webservice代码片段

StreamSource xmlSource = new StreamSource(new StringReader(soapBody));  
        URL wsdlURL = new URL(wsdlUrl);  
        QName serviceQName = new QName(targetNamespace, serviceName);  
        Service service = Service.create(wsdlURL, serviceQName);  

        //创建port端口及 Dispatch<Source>对像  
        QName portQName = new QName(targetNamespace, portName);  
        Dispatch<Source> dispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);  
        Source orderSource = dispatch.invoke(xmlSource);

走到这一步
Source orderSource = dispatch.invoke(xmlSource);
报错:
javax.xml.ws.WebServiceException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,57]
Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#ElementPrefixUnbound?soapenv&soapenv:Envelope
at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175)
at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128)
at org.apache.axis2.jaxws.message.impl.MessageImpl.getAsSOAPMessage(MessageImpl.java:328)
at org.apache.axis2.jaxws.client.dispatch.BaseDispatch.getBodyElementQNameFromDispatchMessage(BaseDispatch.java:403)
at org.apache.axis2.jaxws.client.dispatch.BaseDispatch.getOperationDescriptionForDispatch(BaseDispatch.java:266)
at org.apache.axis2.jaxws.client.dispatch.BaseDispatch.invoke(BaseDispatch.java:189)
at cn.linkey.rulelib.S017.R_S017_B001.run(R_S017_B001.java:67)
at cn.linkey.rule.ExecuteEngine.run(ExecuteEngine.java:34)
at cn.linkey.rule.ExecuteEngine.run(ExecuteEngine.java:49)
at cn.linkey.servlet.Action.run(Action.java:165)
at cn.linkey.servlet.Action.doGet(Action.java:23)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
不知道什么原因,用TEST跑这段代码没问题

1个回答

xmlSource这个返回的xml数据可能有问题,可以debug或者打印log看下是不是返回空的或者不正确格式的xml

Night_zzz
Night_zzz 用main函数跑这段代码,返回的都没问题,主要是放到平台上就解析错误了,请问下大佬会不会和tomcat的什么配置有关系?
3 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问