|
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=&senderService=BS_OA&amp;receiverParty=&amp;receiverService=&amp;interface=SI_PT02PIC&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&receiverParty=&amp;receiverService=&interface=SI_PT02PIC&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=&senderService=BS_WIP&receiverParty=&amp;amp;receiverService=&interface=SI_FICTR&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的设置,就会报类似返回的类型不匹配的错误。如下图:
所以在我已经有了WSDL文件的基础上,我怎么从WSDL文件中获取我JAVA代码所要设置参数的属性,求大神解答?
或者以上问题如何解决,可以让我不报错,成功返回消息。
正确返回的内容应该如下,是一个XML结构的内容。
求大神解答,帮忙解决,急需啊~ |
|