最近在学xfire想了解一个传说中的webservice,但是出了点问题,希望有人能帮我解决一下
报的错:
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Server returned error code = 404 for URI : http://localhost:8080/XFireWebServices/services/HelloWorldSimple. Check server logs for details
org.codehaus.xfire.fault.XFireFault: Server returned error code = 404 for URI : http://localhost:8080/XFireWebServices/services/HelloWorldSimple. Check server logs for details
at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:83)
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.hello(Unknown Source)
at webservice.xfire.simple.Client.main(Client.java:14)
Caused by: org.codehaus.xfire.XFireRuntimeException: Server returned error code = 404 for URI : http://localhost:8080/XFireWebServices/services/HelloWorldSimple. Check server logs for details
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:130)
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)
... 6 more
下面的是完整代码:
[code="java"]
package webservice.xfire.simple;
public interface IHelloWorld extends java.rmi.Remote {
public String hello(String name);
public Float add(Float a, float b);
}
[/code]
[code="java"]
package webservice.xfire.simple;
public class HelloWorld implements IHelloWorld {
private int requestCount = 0;
public Float add(Float a, float b) {
this.requestCount++;
System.out.println("a=" + a + ";b=" + b);
System.out.println("requestCount=" + this.requestCount);
return a + b;
}
public String hello(String name) {
this.requestCount++;
System.out.println("requestCount=" + this.requestCount);
System.out.println("Recived:" + name);
return "Hello:" + name;
}
}
[/code]
[code="java"]
package webservice.xfire.simple;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
public class Client {
public static void main(String[] args) {
String url = "http://localhost:8080/XFireWebServices/services/HelloWorldSimple";
Service service = new ObjectServiceFactory().create(IHelloWorld.class);
try {
IHelloWorld world = (IHelloWorld) new XFireProxyFactory().create(
service, url);
String result = world.hello("user.name");
System.out.println("result=" + result);
System.out.println("result=" + world.add(1f, 2f));
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
[/code]
[code="java"]
<?xml version="1.0" encoding="UTF-8"?>
HelloWebSimple
http://simple.xfire.webservice/HelloWorld
webservice.xfire.simple.IHelloWorld
webservice.xfire.simple.HelloWorld
request
[/code]
上面的代码是我在一个教程上面照着写的,在浏览器中可以看到生成的wsdl文件,