Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a client to consume a webservice

 
Mark Tobin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a webservice

@WebMethod(operationName = "SendMessage")
@WebResult(name = "messages")
public Messages sendMessage(request message) throws WebServiceException;

I want to create a client that will call sendMessage.

In RMI you generate a stub that the client can import. That way the client knows the method name an parameters of the service endpoint

Working of this tutorial

http://72.5.124.55/javaee/5/docs/tutorial/doc/bnayn.html

client HelloClient wants to call a service HelloService

in the client we have

import helloservice.endpoint.HelloService;


The client imports the service endpoints, which I guess is a stub. But the tutorial has missed out the step on how to create the stub.

Is there a link that explains how to create the service stub so that the client can import it.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd use the wsgen tool that's mentioned on that page; there's also a link that points to further documentation on that.
 
Mark Tobin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ulf

Having problems geeting wsgen to work

My service interface is MessageService

@WebService(targetNamespace = "http://ws.serviceApp.com/messageservice", name = "MessageService")
@SOAPBinding(style = Style.DOCUMENT, parameterStyle = ParameterStyle.BARE, use = Use.LITERAL)
public interface MessageSubmissionService {

@WebMethod(operationName = "SendMessage")
@WebResult(name = "messages")
public WsMessages sendMessage(WsRequest messages) throws WebServiceException;

I am trying to call wsgen this way

wsgen -classpath C:\workspace\serviceApp\webservice\service -servicename http://ws.serviceapp.com/service/MessageService.java

Not sure what I am doing wrong

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe this helps: http://java.sun.com/javase/6/docs/technotes/tools/share/wsgen.html

It says to use the "servicename" parameter only in conjunction with the "wsdl" parameter.
 
Mark Tobin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ulf

I am calling wsgen this way now

wsgen -d C:\tmp -classpath serviceApp.webservice.service.MessageService.java

still not able to create the client wrapper I get an error

Missing SEI

MessageService.java is my ServiceEndPointInterface

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"serviceApp.webservice.service.MessageService.java" is not a classpath, so that doesn't make sense. It's also not a file ("serviceApp/webservice/service/MessageService.java " would be) so it couldn't serve as the SEI.
 
Mark Tobin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry ulf

Really confused now.

Looking at the example

wsgen -cp . example.Stock

example is the classpath an Stock the Service End Point Interface, is that not right


which is why I tried -d C:\tmp -classpath serviceApp.webservice.service.MessageService.java an get the Missing SEI error

I have also used the full path

wsgen -cp C:\workspace\serviceApp\webservice\serviceMessageSubmissionService.java I still get the Missing SEI error.

Not sure what other combinations I should use. I have given it the path an the file that contains the annotations @WebService not sure what else I should be setting
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wsgen -cp . example.Stock

example is the classpath an Stock the Service End Point Interface, is that not right

No, it's not. The classpath is ".", and the SEI is "example.Stock"

Note that the SEI must be a classname (not a file name), so it wouldn't end in ".java".

Classpath and SEI are two separate parameters that can't be mixed.
 
Mark Tobin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it

I have to point at my classes directory not my java

I run wsgen -cp . serviceApp.webservice.service.MessageServiceImpl


For any one else also new to this, you have to run it against the MessageServiceImpl if you run it against the interface MessageService you will get the following error

The class "serviceApp.webservice.service.MessageService" is not an endpoint implementation class.

Thanks Ulf for all your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic