67,512
社区成员
发帖
与我相关
我的任务
分享
IHelloWorldService.java:
package com.softfz.xfile.test;
public interface IHelloWorldService {
public String sayHello(String name);
}
HelloWorldServiceImpl.java:
package com.softfz.xfile.test;
public class HelloWorldServiceImpl {
public String sayHello(String name){
return "hello,"+name;
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
webservice.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xfire.codehaus.org/config/1.0">
<service>
<name>HelloWorldService</name>
<serviceClass>
com.softfz.xfile.test.IHelloWorldService
</serviceClass>
<implementationClass>
com.softfz.xfile.test.HelloWorldServiceImpl
</implementationClass>
<style>wrapped</style>
<use>literal</use>
<scope>application</scope>
</service>
</beans>
package com.softfz.xfile.test;
import java.net.MalformedURLException;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
public class HelloWorldClient {
public static void main(String args[]) {
Service srvcModel = new ObjectServiceFactory()
.create(IHelloWorldService.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());
String helloWorldURL = "http://localhost:8080/test/services/HelloWorldService";
try {
IHelloWorldService srvc = (IHelloWorldService) factory.create(
srvcModel, helloWorldURL);
System.out.print(srvc.sayHello("dennis"));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
Exception in thread "main" org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Illegal argument invoking 'com.softfz.xfile.test.IHelloWorldService.sayHello(java.lang.String)': object is not an instance of declaring class
org.codehaus.xfire.fault.XFireFault: Illegal argument invoking 'com.softfz.xfile.test.IHelloWorldService.sayHello(java.lang.String)': object is not an instance of declaring class
at org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
at org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Client.onReceive(Client.java:406)
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
at org.codehaus.xfire.client.Client.invoke(Client.java:336)
at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
at $Proxy0.sayHello(Unknown Source)
at com.softfz.xfile.test.HelloWorldClient.main(HelloWorldClient.java:30)
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://localhost:8080/test/services/HelloWorldService" xmlns:tns="http://localhost:8080/test/services/HelloWorldService" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://localhost:8080/test/services/HelloWorldService" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <xsd:element name="sayHello">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
- <xsd:element name="sayHelloResponse">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="sayHelloRequest">
<wsdl:part name="parameters" element="tns:sayHello" />
</wsdl:message>
- <wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters" element="tns:sayHelloResponse" />
</wsdl:message>
- <wsdl:portType name="HelloWorldServicePortType">
- <wsdl:operation name="sayHello">
<wsdl:input name="sayHelloRequest" message="tns:sayHelloRequest" />
<wsdl:output name="sayHelloResponse" message="tns:sayHelloResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="HelloWorldServiceHttpBinding" type="tns:HelloWorldServicePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="sayHello">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="sayHelloRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="sayHelloResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="HelloWorldService">
- <wsdl:port name="HelloWorldServiceHttpPort" binding="tns:HelloWorldServiceHttpBinding">
<wsdlsoap:address location="http://localhost:8080/test/services/HelloWorldService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>