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

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的设置,就会报类似返回的类型不匹配的错误。如下图:

Java报错

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


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


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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Java项目出现"org.apache.axis.description"不存在的问题,通常是由于缺少相应的依赖库或配置引起的。 org.apache.axis.description是Apache Axis框架的一个,提供了描述和管理Web服务接口以及相关配置的类和接口。如果在项目出现该错误,有以下几种可能的原因和解决方法: 1. 缺少Axis依赖库:在Java项目使用Axis框架时,需要在项目的构建路径添加对应的Axis相关依赖库。可以通过Maven或手动下载并导入这些依赖库。确保在项目含了axis.jar等相关的Axis库文件。 2. 版本兼容性问题:检查使用的Axis版本与项目要求的版本是否一致。如果存在版本兼容性问题,可能会导致org.apache.axis.description的类无法找到。尝试升级或降级Axis版本以解决这个问题。 3. 缺少配置文件:Axis框架通常需要一个配置文件来指定Web服务接口的位置和相关配置。确保项目含了正确的Axis配置文件,比如axis-config.xml。并且,该配置文件需要正确地指定org.apache.axis.description的位置和其他相关配置项。 4. 引入错误名:请检查代码import的名是否正确,比如检查是否将org.apache.axis.description写成了其他的类似名字。 总之,解决"org.apache.axis.description不存在"的问题需要确保项目含了正确的依赖库、配置文件,并且使用了与项目要求的版本相匹配的Axis库。如果仍然存在问题,可以进一步检查代码和项目配置,查找其他可能的原因。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值