java调用delphi写的webservice的问题

Description of your first forum.

java调用delphi写的webservice的问题

帖子hfutzhu » 星期二, 2009年7月14日 22:26


大家帮我看看,无从下手!!!

 delphi做的webservice:wsdl地址:http://localhost:8088/hello/hello.dll/wsdl/IIHello
  <?xml version="1.0" encoding="utf-8" ?>
- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="IIHelloservice" targetNamespace="http://tempuri.org/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns1="urn:IHelloIntf">
- <types>
- <xs:schema targetNamespace="urn:IHelloIntf" xmlns="urn:IHelloIntf">
- <xs:simpleType name="TEnumTest">
- <xs:restriction base="xs:string">
  <xs:enumeration value="etNone" />
  <xs:enumeration value="etAFew" />
  <xs:enumeration value="etSome" />
  <xs:enumeration value="etAlot" />
  </xs:restriction>
  </xs:simpleType>
- <xs:complexType name="TDoubleArray">
- <xs:complexContent>
- <xs:restriction base="soapenc:Array">
  <xs:sequence />
  <xs:attribute ref="soapenc:arrayType" n1:arrayType="xs:double[]" xmlns:n1="http://schemas.xmlsoap.org/wsdl/" />
  </xs:restriction>
  </xs:complexContent>
  </xs:complexType>
- <xs:complexType name="TMyEmployee">
- <xs:sequence>
  <xs:element name="LastName" type="xs:string" />
  <xs:element name="FirstName" type="xs:string" />
  <xs:element name="Salary" type="xs:double" />
  </xs:sequence>
  </xs:complexType>
  </xs:schema>
  </types>
- <message name="echoEnum0Request">
  <part name="Value" type="ns1:TEnumTest" />
  </message>
- <message name="echoEnum0Response">
  <part name="return" type="ns1:TEnumTest" />
  </message>
- <message name="echoDoubleArray1Request">
  <part name="Value" type="ns1:TDoubleArray" />
  </message>
- <message name="echoDoubleArray1Response">
  <part name="return" type="ns1:TDoubleArray" />
  </message>
- <message name="echoMyEmployee2Request">
  <part name="Value" type="ns1:TMyEmployee" />
  </message>
- <message name="echoMyEmployee2Response">
  <part name="return" type="ns1:TMyEmployee" />
  </message>
- <message name="echoDouble3Request">
  <part name="Value" type="xs:double" />
  </message>
- <message name="echoDouble3Response">
  <part name="return" type="xs:double" />
  </message>
- <message name="sayHello4Request">
  <part name="name" type="xs:string" />
  </message>
- <message name="sayHello4Response">
  <part name="return" type="xs:string" />
  </message>
- <portType name="IIHello">
- <operation name="echoEnum">
  <input message="tns:echoEnum0Request" />
  <output message="tns:echoEnum0Response" />
  </operation>
- <operation name="echoDoubleArray">
  <input message="tns:echoDoubleArray1Request" />
  <output message="tns:echoDoubleArray1Response" />
  </operation>
- <operation name="echoMyEmployee">
  <input message="tns:echoMyEmployee2Request" />
  <output message="tns:echoMyEmployee2Response" />
  </operation>
- <operation name="echoDouble">
  <input message="tns:echoDouble3Request" />
  <output message="tns:echoDouble3Response" />
  </operation>
- <operation name="sayHello">
  <input message="tns:sayHello4Request" />
  <output message="tns:sayHello4Response" />
  </operation>
  </portType>
- <binding name="IIHellobinding" type="tns:IIHello">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="echoEnum">
  <soap:operation soapAction="urn:IHelloIntf-IIHello#echoEnum" style="rpc" />
- <input message="tns:echoEnum0Request">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </input>
- <output message="tns:echoEnum0Response">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </output>
  </operation>
- <operation name="echoDoubleArray">
  <soap:operation soapAction="urn:IHelloIntf-IIHello#echoDoubleArray" style="rpc" />
- <input message="tns:echoDoubleArray1Request">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </input>
- <output message="tns:echoDoubleArray1Response">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </output>
  </operation>
- <operation name="echoMyEmployee">
  <soap:operation soapAction="urn:IHelloIntf-IIHello#echoMyEmployee" style="rpc" />
- <input message="tns:echoMyEmployee2Request">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </input>
- <output message="tns:echoMyEmployee2Response">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </output>
  </operation>
- <operation name="echoDouble">
  <soap:operation soapAction="urn:IHelloIntf-IIHello#echoDouble" style="rpc" />
- <input message="tns:echoDouble3Request">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </input>
- <output message="tns:echoDouble3Response">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </output>
  </operation>
- <operation name="sayHello">
  <soap:operation soapAction="urn:IHelloIntf-IIHello#sayHello" style="rpc" />
- <input message="tns:sayHello4Request">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </input>
- <output message="tns:sayHello4Response">
  <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:IHelloIntf-IIHello" />
  </output>
  </operation>
  </binding>
- <service name="IIHelloservice">
- <port name="IIHelloPort" binding="tns:IIHellobinding">
  <soap:address location="http://localhost:8088/hello/hello.dll/soap/IIHello" />
  </port>
  </service>
  </definitions>

用java调用以上webservice代码:
import java.rmi.RemoteException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.*;
public class WSDEMO {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Service service = new Service();
        try {
Call call = (Call)service.createCall();
call.setTargetEndpointAddress("http://localhost:8088/hello/hello.dll/soap/IIHello");
call.setOperationName(new javax.xml.namespace.QName( "sayHello"));
call.addParameter("name",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
String name = "xxx";
try {
String dd = (String)call.invoke(new Object[]{"xxx"});
System.out.println(dd);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

错误:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException
at org.apache.axis.configuration.FileProvider.configureEngine(FileProvider.java:179)
at org.apache.axis.AxisEngine.init(AxisEngine.java:172)
at org.apache.axis.AxisEngine. <init>(AxisEngine.java:156)
at org.apache.axis.client.AxisClient. <init>(AxisClient.java:52)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service. <init>(Service.java:113)
at WSDEMO.main(WSDEMO.java:16)