Problems to create webservice jax-ws on WebSphere 8.5 - java

I'm using Eclipse Juno to create jax-ws webservice on WebSphere® Application Server V8.5 Tools. The WebService sometimes are created but most often he fails to create wsdl. For example, if i try to create a simple webservice named Web:
import javax.jws.WebMethod;
import javax.jws.WebService;
#WebService
public class Web {
#WebMethod
public String getName() {
return "myName";
}
}
After deploying this webservice and viewing WebSphere administration page there is no service named WebService. I tried too access the generated WebSphere wsdl from the url localhost:9080/MyProject/WebService/WebService.wsdl but this not exists.
My project have a configured MANIFEST file that contains:
Manifest-Version: 1.0
UseWSFEP61ScanPolicy: true
I'm actually using servlet 3.0 but tried with 2.3. Anyone can help me to do WebSphere approprieate scan annotations of ws-jax and create wsdl on server?

I found a solution when WebSphere not found WebServices. I modify MANIFESTFILE propertie UseWSFEP61ScanPolicy to false, restart the service and modify angain to true, restart the service and he works.

Related

WebSphere 9 : JAX-WS WebService Unable to Deploy

My Project recently decided to move to WebSphere 9 from WAS 8.5.5.6 and as part of this upgrade, we had JAX-WS services that needs to work as-is.
A little background on services - We had been using SUN Reference Implementation (sun-jaxws.xml) which was easier to configure, however with WAS upgrade sun-jaxws.xml file is now completely ignored along with the web.xml entries we had.
Steps we took to migrate from 8.5.5.6 to 9:
Migrated web.xml spec to 3.1 and removed all entries which were specific to Sun reference implementation (e.g. WSServletContextListener, or WSServlet and all the <servlet> and <servlet-mapping> entries)
Each of our services by default had #WebService annotation so we didn't had to make any changes there.
All our EJB's were modified from EJB 3.1 to EJB 3.2 - Again, since all of our code was already using Java based annotations, we didn't had to make any changes (just updated ejb-jar.xml to 3.2)
After doing the changes, we deployed the application and initially I got one common error for most of the web services:
JAX-WS Service Descriptions could not be correctly built because of the following error: javax.xml.ws.WebServiceException
Caused by: java.lang.Exception: A WSDL Definition could not be generated for the implementation class: gov.state.ServiceImpl
at com.ibm.ws.websvcs.wsdl.WASWSDLGenerator.generateWsdl(WASWSDLGenerator.java:257)
After getting the above error, I added wsdlLocation attribute on my web service implementation class as below:
#javax.jws.WebService(endpointInterface = "gov.state.ServiceIntegrationBean",
targetNamespace = "http://st.services.state.gov",
serviceName = "ServiceIntegrationService",
portName = "ServiceIntegration",
wsdlLocation="wsdl/ServiceIntegration/ServiceIntegration.wsdl")
The Error went away, server started all well - But my WSDL is not hitting the URL I configured..
Does anyone have any idea on what else I could be doing wrong.. or perhaps, if anyone knows how to re-use Sun Reference Implementation of JAX-WS WebServices on WebSphere 9?
Any help will be much appreciated.

Accessing web service by application name not bean name oracle 12c?

I have a webservice deployed on oracle weblogic 12c. The application name is MyWebService, and the service name is CalculatorWS, the EJB name is CalculatorWSSessionEJBBean.
The web service have been created with jdeveloper compatible with weblogic 11g.
On 11g, I can access the service through the application name as:
http://ipAddress:port/MyWebService/CalculatorWS?WSDL
On 12c, using the same deployment, I cannot access the web service through this URL, but with:
http://ipAddress:port/CalculatorWSSessionEJBBean/CalculatorWS?WSDL
Bean Annotations
#Stateless(name = "CalculatorWSSessionEJB", mappedName = "MyWebService")
#WebService( serviceName ="CalculatorWS")
// set the binding to use SOAP version 1.2
#BindingType(value="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/")
public class CalculatorWSSessionEJBBean
How can I consolidate the URL for both versions of weblogic?
The only solution I could come up with was to change the main webservice class name to MyWebService, this way I got the same URL working for both versions.

Configuring a Jetty server with Glassfish servlet

I have a working web-application that I built, successfully deployed to Heroku, and is functioning well. However, I'm trying to tune the server/servlet config, and that's when I realized that I don't know what my application is actually doing.
For glassfish, this is the config that's needed.
However, for Jetty, this is the config that's needed.
I realized I have no idea which of the above my application is actually using, so I started digging in my code and found the following:
The main method being called by Heroku is instantiating the following Jetty server/webappcontext.
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
However, the jetty config seems to rely on a number of files (such as etc/jetty.xml, webapps folder or war files) which my project does not have at all.
In addition, my web.xml file defines the following servlet:
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
The fact that my application is defining a Jetty server but Glassfish servlet concerned me quite a bit. In an effort to standardize everything around Jetty, I tried adding the jetty servlet to my pom.xml dependencies and changed the above to:
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
However, this change caused my application to break. It still compiles successfully and all my jerset-test based integration tests still succeed locally. But when I actually run the server, none of the routes work.
Some questions:
Is it a ill-advised to use a Jetty server along with a Glassfish servlet (container)?
If yes, what servlet (container?) should I replace Glassfish with, and what do I need to do to get the new Jetty servlet working?
If no, what config should I be using for my current setup? Should I be implementing the Glassfish config or the Jersey config?
I've spent many hours trying to read through various documentations, tutorials and stack-overflow threads, but they all either assume prior knowledge about servlets, JavaEE and related topics (none of which I'm familiar with), or they are oriented towards building brand new hello-world apps from scratch (as opposed to porting an existing working app over, which is what I'm trying to do). Any explanations you could give, without assuming prior knowledge, relevant to the context described above, would be much appreciated.
Edit: I think I'm starting to understand now that a Servlet is the code that generates the response for a request, and the ServletContainer is what provides the infrastructure for the Servlet. I've never had to deal with Servlets directly in building my web-app. Here's an example of what a route looks like in my app:
#Path(Ping.REST_PREFIX)
public class Ping {
static final String REST_PREFIX = "/ping";
#GET
public static Response get(#DefaultValue("getPing") #QueryParam("param") String param) {
return Response.ok().entity(param).build();
}
#Path("/pong")
#GET
public static Response getPong(#DefaultValue("getPong") #QueryParam("param") String param) {
return Response.ok().entity(param).build();
}
}
How can I port code like the above into a Jetty ServletContainer, without rewriting vast sections of my application?
You are not using a "Glassfish Servlet Container", you are using a "Jersey Servlet Container".
Jersey is the project you are using.
Glassfish was the umbrella organization (sometimes called "a forge") that helps manage/maintain the Jersey project (along with dozens of other projects).
Difference com.sun.jersey and org.glassfish.jersey
The Jersey project can now be found at the java.net organization.
https://jersey.java.net/

Change JAX-WS listening url

Alright, this might look like a duplicate question but I have struggled a lot but haven't found a proper solution. Closest match I found is this: JaxWS application URL in Tomcat
But this is using something different.
I am using Glassfish 3 and developing in Netbeans 7.4 along with Spring, Spring MVC. I have developed my webservice using following code:
#WebService(serviceName = "FooService")
public class FooWS {
#WebMethod(operationName="getHelloWorld")
public String getHelloWorld() {
return "Hi";
}
}
Now the problem is that, it start listening at this address http://localhost:8080/myapp/FooService
But I want it to listen at http://localhost:8080/myapp/ws/FooService.
I do not have any xml in my project for configuring web services. I only have following xmls in WEB-INF
applicationContext.xml
dispatcherServlet.xml
glassfish-web.xml
spring-security.xml
web.xml
Except glassfish-web.xml netbeans haven't generated any code for my webservice in any other xml file. And also in this file there is no source, just there is a section for Web Services which shows this web service, I am attaching image for the same.
Does anybody knows where should I make changes to change listening url? Or any annotation that might help?
I found this answer https://stackoverflow.com/a/8975619/601168 but I guess this is for clients only.

Generate Wsdl/Client Stubs For Web Service

I have been doing some reading up on web services programming with Java, Eclipse, etc. and I found one particular example where the person created the web service and client by doing the following:
define the web service java class (interface + impl)
deploy the web service using Endpoint.publish
grab the wsdl from the url of the web service (eg, localhost://greeting?wsdl)
use wsimport to generate stubs
create a client class using generated stubs
Is there another way to generate the wsdl without having to publish the web service and download it? Perhaps a maven plugin to auto-generate wsdl and client stubs?
Update: Rather than creating a new question I am just going to piggyback on this one.
I have created my web service by defining an interface:
#WebService
public interface HelloWorldWs {
#WebMethod
public String sayHello(String name);
}
and an impl class:
#WebService(endpointInterface = "com.me.helloworldws.HelloWorldWs")
public class HelloWorldWsImpl implements HelloWorldWs {
#Override
#WebMethod
public String sayHello(String name) {
return "Hello World Ws, " + name;
}
}
When I run wsgen I get the following error:
The #javax.jws.WebMethod annotation cannot be used in with #javax.jws.WebService.endpointInterface element.
Eclipse seems to be okay with it.
Any idea why?
Note, I originally did not have the annotation but when I tried to call my webservice I got the following error:
com.me.helloworldws.HelloWorldWsImpl is not an interface
The JSR 224 says in 3.1 section:
An SEI is a Java interface that meets all of the following criteria:
Any of its methods MAY carry a javax.jws.WebMethod annotation (see 7.11.2).
javax.jws.WebMethod if used, MUST NOT have the exclude element set to true.
If the implementation class include the javax.jws.WebMethod, then you cant put #WebMethod(exclude=true) and that in not possible, according to specification.
Depends of custom version of Eclipse, shows a warning for this. e.g. Rational Application Developer for Websphere shows:
JSR-181, 3.1: WebMethod cannot be used with the endpointInterface
property of WebService
While programming/building a project (with some advanced IDE) normally you should be able to find it between auto-generated stuff - the IDE should generate it. Just check carefully.

Categories