AXIS客户端调用出错org.apache.axis.NoEndPointException

在使用Eclipse创建Web Service Client并尝试调用WCF服务时,遇到AxisFault Server.NoEndpoint错误。通过分析错误,发现需要实例化服务定位器后再获取Stub,最终成功调用服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近研究WCF,希望WCF的服务能够给不同的开发语言调用,测试了Java,遇到这个问题。


首先通过Eclipse 建立一个Web Service Client,引用到WCF服务,会生成以下几个主要文件:

org.tempuri.AuthCommon;
org.tempuri.AuthCommonLocator;

org.tempuri.BasicHttpBinding_IAuthCommonStub;

org.tempuri.IAuthCommon;

org.tempuri. IAuthCommonProxy ;


以为直接 new BasicHttpBinding_IAuthCommonStub 就可以,如下

BasicHttpBinding_IAuthCommonStub serviceStub= new BasicHttpBinding_IAuthCommonStub();
String test = serviceStub.doWork();

结果报了以下错误:

AxisFault
 faultCode: {http://xml.apache.org/axis/}Server.NoEndpoint
 faultSubcode:
 faultString: No endpoint
 faultActor:
 faultNode:
 faultDetail:
    {http://xml.apache.org/axis/}exceptionName:org.apache.axis.NoEndPointException
    {http://xml.apache.org/axis/}stackTrace:No endpoint
    at org.tempuri.BasicHttpBinding_IAuthCommonStub.doWork(BasicHttpBinding_IAuthCommonStub.java:90)
    at cn.iruby.test.TestAuth.main(TestAuth.java:28)

    {http://xml.apache.org/axis/}hostname:Yuandh-PC

No endpoint
    at org.tempuri.BasicHttpBinding_IAuthCommonStub.doWork(BasicHttpBinding_IAuthCommonStub.java:90)
    at cn.iruby.test.TestAuth.main(TestAuth.java:28)


google了一下,原来要这样

AuthCommon service = new AuthCommonLocator();
BasicHttpBinding_IAuthCommonStub serviceStub= (BasicHttpBinding_IAuthCommonStub) service.getBasicHttpBinding_IAuthCommon();
String test = serviceStub.doWork();


OK。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值