<?xml version="1.0" encoding="UTF-8" ?>
- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:Foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="MyHelloService" targetNamespace="urn:Foo">
  <types />
- <message name="HelloIF_sayHello">
  <part name="String_1" type="xsd:string" />
  </message>
- <message name="HelloIF_sayHelloResponse">
  <part name="result" type="xsd:string" />
  </message>
- <portType name="HelloIF">
- <operation name="sayHello" parameterOrder="String_1">
  <input message="tns:HelloIF_sayHello" />
  <output message="tns:HelloIF_sayHelloResponse" />
  </operation>
  </portType>
- <binding name="HelloIFBinding" type="tns:HelloIF">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
- <operation name="sayHello">
  <soap:operation soapAction="" />
- <input>
  <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
  </input>
- <output>
  <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="urn:Foo" />
  </output>
  </operation>
  </binding>
- <service name="MyHelloService">
- <port name="HelloIFPort" binding="tns:HelloIFBinding">
  <soap:address location="http://localhost:8080/hello-jaxrpc/hello" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
  </port>
  </service>
  </definitions>我的客户端用的是SAAJ写的,代码如下:package saaj;import javax.xml.soap.*;
import java.util.*;
import java.net.URL;public class SoapRequestExample {
public static void main(String[] args) {
/* String endpointAddress = "http://localhost:8080/hello-jaxrpc/hello"; */
String endpointAddress = "http://localhost:8080/Axis2/services/HelloWorld";
try {SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory
.newInstance();
SOAPConnection connection = soapConnectionFactory
.createConnection();
SOAPFactory soapFactory = SOAPFactory.newInstance();MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
SOAPHeader header = message.getSOAPHeader();SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
header.detachNode();Name bodyName = soapFactory.createName("sayHello", null,
"urn:Foo");
SOAPBodyElement bodyElement = body.addBodyElement(bodyName);Name name = soapFactory.createName("s");
SOAPElement symbol = bodyElement.addChildElement(name);
symbol.addTextNode("duke");
message.saveChanges();
message.writeTo(System.out);
System.out.println();URL endpoint = new URL(endpointAddress);
SOAPMessage response = connection.call(message, endpoint);
connection.close();SOAPBody soapBody = response.getSOAPBody();
System.out.println("soapBody====" + response.getSOAPBody());} catch (Exception ex) {
ex.printStackTrace();
}
}}
然后得到如下的错误:Sep 24, 2008 1:34:19 PM com.sun.xml.messaging.saaj.soap.MessageImpl identifyContentType
SEVERE: SAAJ0536: Content-Type needs to be Multipart/Related and with type=text/xml or application/soap+xml
Sep 24, 2008 1:34:19 PM com.sun.xml.messaging.saaj.soap.MessageImpl <init>
SEVERE: SAAJ0535: Unable to internalize message 顺便提一下,这个WEBSERVICE我是用jaxrpc写的,用AXIS2做客户端竟然访问时也是上述的错误,而我用AXIS2写的客户端调用以前AXIS2写的WEBSERVICE都一切正常,急死了