设为首页 收藏本站
查看: 987|回复: 0

[经验分享] Java代码中利用apache.axis包调用 WebService 报Server Error错误,Java代码中根据WebService参数需要怎么解析设置

[复制链接]

尚未签到

发表于 2017-1-15 07:43:08 | 显示全部楼层 |阅读模式
  Java代码中利用apache.axis包调用 WebService 报Server Error错误,Java代码中根据WebService参数需要怎么解析设置?

WebService 代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:p1="http://battery.com/OA/PT02PIC" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="SI_PT02PIC" targetNamespace="http://atlbattery.com/OA/PT02PIC">
<wsdl:documentation/>
<wsdl:types>
<xsd:schema targetNamespace="http://battery.com/OA/PT02PIC" xmlns="http://battery.com/OA/PT02PIC" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="MT_PT02PIC" type="DT_PT02PIC"/>
<xsd:element name="MT_PT02PIC_REQ" type="DT_PT02PIC_REQ"/>
<xsd:complexType name="DT_PT02PIC_REQ">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">df595fa2460711e4c39d000000429b5e</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="L_SUBRC">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">3ed9e744454311e4b98820107a6cb7a5</xsd:appinfo>
<xsd:documentation>S:成功   E:失败</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:length value="1"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="L_MESSAGE">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">b4fe0f7b460711e4a7b220107a6cb7a5</xsd:appinfo>
<xsd:documentation>消息</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="255"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DT_PT02PIC">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">20825fc9462211e4c168000000429b5e</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="SYSNAME">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">ab3bba74454211e4978a20107a6cb7a5</xsd:appinfo>
<xsd:documentation>ATL OR  CATL</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="3"/>
<xsd:maxLength value="4"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="MAKEY">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">20b9f767454311e4cc6d20107a6cb7a5</xsd:appinfo>
<xsd:documentation>资料主ID</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="KMURL">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">20b9f769454311e4802820107a6cb7a5</xsd:appinfo>
<xsd:documentation>KM访问地址</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="255"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="FILENAME">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">8051361c460711e4bf3c20107a6cb7a5</xsd:appinfo>
<xsd:documentation>文件名</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="200"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="MT_PT02PIC">
<wsdl:documentation/>
<wsdl:part name="MT_PT02PIC" element="p1:MT_PT02PIC"/>
</wsdl:message>
<wsdl:message name="MT_PT02PIC_REQ">
<wsdl:documentation/>
<wsdl:part name="MT_PT02PIC_REQ" element="p1:MT_PT02PIC_REQ"/>
</wsdl:message>
<wsdl:portType name="SI_PT02PIC">
<wsdl:documentation/>
<wsdl:operation name="SI_PT02PIC">
<wsdl:documentation/>
<wsp:Policy>
<wsp:PolicyReference URI="#OP_SI_PT02PIC"/>
</wsp:Policy>
<wsdl:input message="p1:MT_PT02PIC"/>
<wsdl:output message="p1:MT_PT02PIC_REQ"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SI_PT02PICBinding" type="p1:SI_PT02PIC">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
<wsdl:operation name="SI_PT02PIC">
<soap:operation soapAction="http://sap.com/xi/WebService/soap1.1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
<wsdl:input>
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SI_PT02PICService">
<wsdl:port name="HTTP_Port" binding="p1:SI_PT02PICBinding">
<soap:address location="http://ndsapd111.atlbattery.com:50900/XISOAPAdapter/MessageServlet?senderParty=&amp;senderService=BS_OA&amp;amp;receiverParty=&amp;amp;receiverService=&amp;amp;interface=SI_PT02PIC&amp;interfaceNamespace=http%3A%2F%2Fatlbattery.com%2FOA%2FPT02PIC" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:port>
<wsdl:port name="HTTPS_Port" binding="p1:SI_PT02PICBinding">
<soap:address location="https://ndsapd111.atlbattery.com:50901/XISOAPAdapter/MessageServlet?senderParty=&;amp;senderService=BS_OA&amp;receiverParty=&amp;amp;receiverService=&amp;interface=SI_PT02PIC&amp;interfaceNamespace=http%3A%2F%2Fatlbattery.com%2FOA%2FPT02PIC" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:port>
</wsdl:service>
<wsp:UsingPolicy wsdl:required="true"/>
<wsp:Policy wsu:Id="OP_SI_PT02PIC"/>
</wsdl:definitions>
  

Java代码如下:

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import javax.xml.namespace.QName;
import java.net.URL;
public class Main {
public static void main(String[] args) {

try {
String endpoint = "http://ndsapd111.atlbattery.com:50900/XISOAPAdapter/MessageServlet?senderParty=&amp;senderService=BS_WIP&amp;receiverParty=&amp;amp;amp;receiverService=&amp;interface=SI_FICTR&amp;interfaceNamespace=http%3A%2F%2Fatlbattery.com%2FWIP%2FFICTR_SEARCH";
Service  service = new Service();      
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName( "SI_FICTR" );      
call.setOperationName(new QName(endpoint, "SI_FICTR"));     
System.out.println(call);
call.addParameter("SYSNAME", XMLType.XSD_STRING, ParameterMode.IN);      
call.addParameter("BUKRS", XMLType.XSD_STRING, ParameterMode.IN);      
call.setUsername("CX");
call.setPassword("123456");
call.setReturnType( XMLType.QNAME_LITERAL_ITEM );     
String ret = (String) call.invoke(new Object[] { "ATL","1030" });
System.out.println(ret);

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}
  

报错截图:[img=http://img.bbs.csdn.net/upload/201503/18/1426689718_459371.jpg][/img]

报错内容如下:

- Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
org.apache.axis.client.Call@6be46e8f
1
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultSubcode:
faultString: Server Error
faultActor:
faultNode:
faultDetail:
{http://sap.com/xi/WebService/xi2.0}SystemError:
<context>XIAdapter</context>
<code>ADAPTER.JAVA_EXCEPTION</code>
<text><![CDATA[
com.sap.aii.af.service.cpa.CPAObjectNotFoundException: Couldn't retrieve inbound binding for the given P/S/A values: FP=;TP=;FS=null;TS=;AN=null;ANS=null;
at com.sap.aii.af.service.cpa.impl.lookup.CommonLookup.getInboundBinding(CommonLookup.java:250)
at com.sap.aii.af.service.cpa.impl.lookup.CommonLookup.getInboundBinding(CommonLookup.java:171)
at com.sap.engine.core.thread.execution.Executable.run(Executable.java:101)
at com.sap.engine.core.thread.execution.CentralExecutor$SingleThread.run(CentralExecutor.java:328)
]]></text>

Server Error
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at Main.main(Main.java:34)
  


我估计是Java中OperationName的问题,我修改了OperationName的设置,就会报类似返回的类型不匹配的错误。如下图:
DSC0000.png

所以在我已经有了WSDL文件的基础上,我怎么从WSDL文件中获取我JAVA代码所要设置参数的属性,求大神解答?
或者以上问题如何解决,可以让我不报错,成功返回消息。

  
正确返回的内容应该如下,是一个XML结构的内容。
DSC0001.png

求大神解答,帮忙解决,急需啊~

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-328511-1-1.html 上篇帖子: api接口简明,比Apache Common File Upload速度快、稳定性高,无需任何第三方库的上传组建 下篇帖子: Apache配置参考本篇文章来源于:开发学院 http://edu.codepub.com 原文链接:http://edu.codepub.com/2009
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表