根据已有wsdl文件用axis建立web   service服务

根据已有wsdl文件用axis建立web   service服务

首先wsdl文件是:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://file.upload"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://file.upload"
xmlns:intf="http://file.upload"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

<wsdl:types>
<schema targetNamespace="http://file.upload" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="sayHello" type="xsd:anyType"/>
<element name="sayHelloReturn" type="xsd:anyType"/>
</schema>
</wsdl:types>

  <wsdl:message name="sayHelloRequest">
    <wsdl:part element="impl:sayHello" name="part"/>
  </wsdl:message>
 
  <wsdl:message name="sayHelloResponse">
    <wsdl:part element="impl:sayHelloReturn" name="sayHelloReturn"/>
  </wsdl:message>
 
  <wsdl:portType name="HelloSayer">
    <wsdl:operation name="sayHello">
      <wsdl:input message="impl:sayHelloRequest" name="sayHelloRequest"/>
      <wsdl:output message="impl:sayHelloResponse" name="sayHelloResponse"/>
    </wsdl:operation>
  </wsdl:portType>
 
  <wsdl:binding name="HelloServiceSoapBinding" type="impl:HelloSayer">
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sayHello">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="sayHelloRequest">
        <wsdlsoap:body namespace="http://file.upload" use="literal"/>
      </wsdl:input>
      <wsdl:output name="sayHelloResponse">
        <wsdlsoap:body namespace="http://file.upload" use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="HelloSayerService">
    <wsdl:port binding="impl:HelloServiceSoapBinding" name="HelloService">
      <wsdlsoap:address location="http://localhost:8082/WebService/services/HelloService"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

其次根据这个文件用代码生成一个可调用的web service,注意这个wsdl的style是message:
WSDDDeployment deployment = getWSDDDeployment();

Collection portTypes = wsdl.getPortTypes().values();
for (Iterator portIter = portTypes.iterator(); portIter.hasNext();) {
// SOAPService service = new SOAPService(new MsgProvider());
WSDDService service = new WSDDService();
ServiceDesc desc = service.getServiceDesc();
service.setQName(new QName(name));
service.setName(name);
service.setProviderQName(new QName(WSDDConstants.URI_WSDD_JAVA,
"MsbusProvider"));
desc.setName(name);
desc.setStyle(Style.MESSAGE);
desc.setUse(Use.LITERAL);
Map nsMap = wsdl.getNamespaces();
desc.setNamespaceMappings(new ArrayList(nsMap.entrySet()));

PortType portType = (PortType) portIter.next();
List operations = portType.getOperations();
for (Iterator oIter = operations.iterator(); oIter.hasNext();) {
Operation operation = (Operation) oIter.next();
Collection inParts = null;
OperationDesc operationDesc = new OperationDesc();
operationDesc.setName(operation.getName());
Input in = operation.getInput();
inParts = in.getMessage().getParts().values();
for (Iterator partIter = inParts.iterator(); partIter.hasNext();) {
Part part = (Part) partIter.next();
ParameterDesc paramDesc = new ParameterDesc();
paramDesc.setName(part.getName());
paramDesc.setQName(new QName(ns, part.getName()));
paramDesc.setTypeQName(new QName(ns, "Element[]"));
paramDesc.setMode(ParameterDesc.IN);

operationDesc.addParameter(paramDesc);
}
Output out = operation.getOutput();
Collection outParts = null;
if (out != null)
outParts = out.getMessage().getParts().values();
if (outParts != null) {
Part part = (Part) outParts.iterator().next();
operationDesc.setReturnQName(new QName(ns, part.getName()));
operationDesc.setReturnType(new QName(ns, "Element[]"));
service.addOperation(new WSDDOperation(operationDesc));
}
}
service.setOptionsHashtable(new Hashtable());
try {
// validate descriptor before deploying service
service.validateDescriptors();
} catch (WSDDException e) {
throw new DeploymentException("Invalid WSDD", e);
}
// config.deployService(name, service);
deployment.deployService(service);
}

运行一个测试程序访问该服务器,报错:

java.lang.ClassCastException: java.util.HashMap$Entry
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 oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1306)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:324)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:291)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:207)
at oracle.xml.jaxp.JXSAXParser.parse(JXSAXParser.java:292)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:1792)
at com.sobey.msbus.engine.test.MsgServiceTester.main(MsgServiceTester.java:41)

实在不知道我代码那里有错,希望高手指点一二,万分感谢.
急急急 还望能解决.
还请大家帮帮忙.