生成web service客户端无法调用异常

http://ask.csdn.net/questions/155170

各位大神:
求助!java用cxf方式把一个wsdl打成了一个包,但是我在源码里用main方法调用报错了。
public static void main(String[] args)throws Exception {
URL wsdlURL = new URL("http://197.3.176.63:50000/cmbcagent_bosent_baseline_webservice_web/AgentAgreementService?wsdl");
System.out.println("11111111");
AgentAgreementService ss = new AgentAgreementService(wsdlURL);
System.out.println("ZZZZZZZ");

    AgentAgreement service =ss.getAgentAgreementPort();//此处报错

}
为什么getAgentAgreementPort()这个get不出来?我只是把这个包的包名修改了。
控制台报错为
Exception in thread "main" javax.xml.ws.WebServiceException: Unable to create JAXBContext
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:83)
at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:244)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:688)
at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:676)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:331)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:314)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:296)
at javax.xml.ws.Service.getPort(Service.java:99)
at com.bosent.agentframework.webservices.channel.agentagreement.AgentAgreementService.getAgentAgreementPort(AgentAgreementService.java:58)
at com.bosent.agentframework.webservices.channel.agentagreement.AgentAgreementService.main(AgentAgreementService.java:79)
Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 110 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://bosent.com/agentframework/webservices/channel/agent/}wuHanBafpModifyPwdForThirdByChannelService". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
万分感谢!!





lovexlm0312    2015.07.22 10:4

删了客户端重新生成哈,我也修改文件中的包名报错,重新生成后就好了

lovexlm0312    2015.07.22 10:42

删了客户端重新生成哈,我也修改文件中的包名报错,重新生成后就好了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Web Service客户调用方式主要有两种:基于代理类的调用和基于动态代理的调用。 1. 基于代理类的调用 在基于代理类的调用中,首先需要使用wsdl.exe命令或者Visual Studio自动生成代理类。然后,通过实例化代理类对象,调用其中的方法来实现与Web Service的交互。 具体实现步骤如下: (1)生成代理类 使用wsdl.exe命令或者Visual Studio自动生成代理类。wsdl.exe是Windows操作系统自带的工具,可以通过命令行调用生成代理类。具体命令如下: ``` wsdl /l:CS /n:MyCompany.MyProduct.MyService http://localhost/MyService/Service.asmx?wsdl ``` 其中,/l:CS表示生成C#代码,/n:MyCompany.MyProduct.MyService表示生成的命名空间,http://localhost/MyService/Service.asmx?wsdl表示Web Service的地址。 (2)实例化代理类对象 在客户代码中,实例化代理类对象。代码示例如下: ``` MyServiceProxy proxy = new MyServiceProxy(); ``` (3)调用代理类中的方法 使用代理类对象调用其中的方法。代码示例如下: ``` string result = proxy.MyMethod(param1, param2); ``` 2. 基于动态代理的调用 基于动态代理的调用是通过反射机制动态生成代理类,然后再通过代理类实现与Web Service的交互。相比于基于代理类的调用,基于动态代理的调用更加灵活,可以动态地修改代理类的行为。 具体实现步骤如下: (1)使用ChannelFactory创建代理类 使用ChannelFactory创建代理类对象。代码示例如下: ``` ChannelFactory<IMyService> factory = new ChannelFactory<IMyService>(new BasicHttpBinding(), new EndpointAddress("http://localhost/MyService/Service.asmx")); IMyService proxy = factory.CreateChannel(); ``` 其中,IMyServiceWeb Service的接口,BasicHttpBinding是通信协议,EndpointAddress是Web Service的地址。 (2)调用代理类中的方法 使用代理类对象调用其中的方法。代码示例如下: ``` string result = proxy.MyMethod(param1, param2); ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值