Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JAX-WS  RSS feed

 
R Bieringa
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm currently working on webservices based on JAX-WS. The webservices are based on EJB 3.
I'm using @Stateless, @Webservice, @DeclareRoles, @RolesAllowed and @WebContext as annotations for each service "as a whole".
I'm using @WebMethod, @WebResult, @RequestWrapper and @ResponseWrapper on the individual methods.

De interface classes have been generated from a WSDL. The WSDL is not referenced by the sources in any way.

Now if I use the URL for the webservice to get the WSDL, in the service-part of the WSDL I get the host(machine) plus the port on which the service runs. I'm referring to the <soap:address location=> part.
E.g.: instead of http://www.webservice.com/services/myservice I get http://amachine:8080/services/myservice in that part of the WSDL.

The webservices are running on multiple JBoss instances. The requests come in on IIS, get loadbalanced and are forwarded to the JBoss instances.

But if I want the URL instead of machinename and port, what are my options ?
Restriction:
I can't use "hardcoded" solutions, because we have a large number of environments, so I would like it best if it was just some sort of annotation.

Regards,
Ronald





 
Shashank Ag
Ranch Hand
Posts: 88
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
only thing you need to do is provide the url (domain name or ip+port) of IIS server as end pont.
Also, hopefully there will be a class generated with <SomePrefix>PortClient.java
Before calling your service create instance of it and call <SomePrefix>PortClient.setEndPoint(<url>);

Hope this will do.
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ronald,
If you want to dynamically set endpoint address of a web service, the best way is to load a properties file containing the address and then set like the way suggested by Shashank.

On the other hand, if you want to generate WSDL with a pre-set endpoint address before generating stub classes, you can't change the endpoint address if you want change again! So, I recommend the earlier approach.
 
R Bieringa
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Well, I don't have a generated portclient. I'm using wsconsume, because we have to conform to an original wsdl.
So I'm a bit puzzled.

Regards,
Ronald
 
Shashank Ag
Ranch Hand
Posts: 88
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two approaches:
1.See whatever method you use to generate client side stubs, there must be a class containing a string varible containing url of service endpoint.
Find it by using grep or search in IDE. And change it to as stated above.

2.Otherwise you can open wsdl file and look url present in definition->service->address->port tag and replace them with the ip/hostname of IIS server.
And regenerate the client stubs. In general this should work.
 
R Bieringa
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think you're referring to calling the webservice. Probably I wasn't clear: The server returns the wsdl.
At the end I see:
<service name="IntermediairWSService">
<port binding="tns:IntermediairWSSoapBinding" name="IntermediairWSSoapPort">
<soap:address location="http://amachine:8080/intermediairws/nl/stater/eservice/intermediair/ws/IntermediairWS.jws" />
</port>
</service>
But in my company would like to see it a bit differently in the soap:address location-attribute:
<soap:address location="http://the.webservice.url/intermediairws/nl/stater/eservice/intermediair/ws/IntermediairWS.jws" />
It's not the most important of things, but we would prefer it if it was possible.

Regards,
Ronald



 
Shashank Ag
Ranch Hand
Posts: 88
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think here is littile confusion, you want to produce (expose) a web service or consume a webservice?
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bieringa,
But in my company would like to see it a bit differently in the soap:address location-attribute:
<soap:address location="http://the.webservice.url/intermediairws/nl/stater/eservice/intermediair/ws/IntermediairWS.jws" />

I see what exactly you mean. When you set DNS name and configuring ISS to expose web service link to outside world, the WSDL link is automatically accessed with updated location attribute(with DNS name followed by your service and port)! Even referenced XSD would have a new url links, which should also be straight away accessible.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!