• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating a client to consume a webservice

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic