简体   繁体   English

如何利用从WSDL生成的Web服务客户端?

[英]How to utilize web service client generated from WSDL?

I'm trying to write a simple web service client to interact with my simple web service which only returns a user id that's passed in. So I created a web service client in eclipse and generated a few files for me; 我正在尝试编写一个简单的Web服务客户端以与我的简单Web服务进行交互,该Web服务仅返回传入的用户ID。 wsCall, wsCallBindingStub, wsCallProxy, wsCallService, wsCallServiceLocator. wsCall,wsCallBindingStub,wsCallProxy,wsCallService,wsCallServiceLocator。 The stub is the conly class I found that has my web service methods in it, because my ws is simple at this stage? 存根是我发现的conly类,其中包含我的Web服务方法,因为在这个阶段我的ws很简单?

So I want to invoke the call, what do I need to make the call? 因此,我想调用该呼叫,我需要拨打什么电话?

I've seen all the examples online have the try-catch for a remote exception or Axis fault, then the classes are instantiated (including a response class, to deserialize?) and make the ws call via the stub class. 我在网上看到的所有示例都有针对远程异常或Axis错误的try-catch,然后实例化了类(包括反序列化的响应类),并通过存根类进行ws调用。 Is that all I need to call for my case? 这是我所需要的全部吗?

wsCallBindingStub stub = new wsCallBindingStub();
String retString = stub.sayHi(1); // 1: my user id
return retString;

Thank you! 谢谢!

Ahh I figured it out, I was getting an error because my wsdl uses the hostname and I needed to specify the ip.. as for the code needed it was pretty much identicle; 嗯,我发现了这个错误,因为我的wsdl使用了主机名,并且需要指定ip ..因为需要的代码几乎是相同的;

wsCall ws = new wsCallServiceLocator().getWsCallPort();
result = ws.sayHi(x);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM