wangdgsc0105 2010-02-07 23:00
浏览 157
已采纳

关于xfire的应用

最近在学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文件,

  • 写回答

2条回答 默认 最新

  • unika_ly12 2010-02-09 08:37
    关注

    [quote]IHelloWorld world = (IHelloWorld) new XFireProxyFactory().create(service, url);[/quote]
    这句改改试下
    [code="java"]
    XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
    IHelloWorld srvc = (IHelloWorld) factory.create(service, url);
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog