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

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.

Related

How to deploy JavaEE 7 / JPA 2.1 Dynamic Web Application to IBM Liberty Profile WITHOUT web.xml

I have a Dynamic Web Application that access a DB2 v10 zOS Database.
I wish to use Hibernate 5 as my JPA 2.1 Provider and access my EntityManager via CDI.
I do not want to use the Spring Framework at all; I also do not wish to have a web.xml file.
How can I configure my persistence context and persistence unit WITHOUT using web.xml when deploying my application to WebSphere Application Server Liberty v9 Beta?
The first result on google for "websphere liberty hibernate" gave me the link to a sample app that uses Liberty with Hibernate.
WASdev Liberty + Hibernate sample
Note that the jpaApp.war DOES use a web.xml, but this can easily be avoided by using the proper #WebServlet annotation and changing the persistence.xml to point to a server-defined datasource instead of a component-defined datasource.
#WebServlet(displayName="JPA Servlet", urlPatterns="/JPAServlet")
public class JPAServlet extends HttpServlet {
// ...
}

Determine WAR context root from MDB

I have a JavaEE ear containing an ejb and war being deployed to GlassFish v3.1.2.2. The war contains a Jersey/Atmosphere application that is using CDI. Within the war, I have an MDB that is asynchronously receiving events it will broadcast using Atmosphere. The message I need to broadcast using Atmosphere needs to includes some links to other resources in the web application.
In order to build those links, like in other places in the code, I would like to use UriBuilder. To do so, I need access to the application's deployed context root, so I can invoke UriBuilder.fromPath(contextRoot)
This Java EE 7 article implies I can inject a ContextServlet into a CDI bean this way:
#Inject ServletContext context;
But this does not work for my MDB. I'm also only on JavaEE6 w/ Glassfish v3.
How can I access the ServletContext from an MDB hosted in my war?
I ended up solving this with the following.
Installed the deltaspike servlet module since I'm on GlassFish v3.1.2.2 which does not have CDI 1.1 which includes a provider for ServletContext out of the box.
Followed the MDB piece of this article to convert my JMS message to a CDI event and then observed that CDI event from a pure CDI bean that had the ServletContext injected in order to build out the required URLs for the Atmosphere message.

Problems to create webservice jax-ws on WebSphere 8.5

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.

Oc4j: Invoking Local EJB from a Web app in the same EAR

I've an EAR app contains two modules.
EJB Module and Web Module.
In web module, I am trying to get a ref to some EJB SLSB, I don't use injection cause the class the I need to invoke the method in is not managed.
I am using the following code from the web module:
IFooBarService service = InitialContext.doLookup("IFooBarService");
IFooBarService: the the Local Interface that defined as ( in the ejb module):
#Local
public interface IFooBarService
{
// ...
}
Do I miss something? (should I supply environment info?)
Are you sure that IFooBarService is the JNDI name the IFooBarService service is bound to? JBoss for example shows the JNDI names in the boot log. You can then use it for lookup purposes.
In general, if you want your app to be portable you shouldn't rely on the server mechanism to generate JNDI names, as the Java EE spec has its own. You should be able to do:
IFooBarService service = InitialContext.doLookup("java:comp/env/IFooBarService");
If you are using newer versions of Java EE (Java EE 6), and want to lookup an EJB which is in the same app but in a different module, you can do:
IFooBarService service = InitialContext.doLookup("java:app/[module name]/IFooBarService");
More info on standard names here.
From Here: https://forums.oracle.com/forums/thread.jspa?threadID=476903
The solution is:
fooBarService = (FooBarService) ((StatelessSessionDefaultLocalHome)
new InitialContext().lookup("EJBModuleName_FooBarServiceLocal")).create();

JBoss web service client host url configuration

I have a ejb3 using a web service and configure the host name of the web service in the ejb-jar.xml file (or #WebServiceRef(wsdlLocation = "http:://myserver/service.wsdl") ). Can I do the same configure outside of the ejb-jar.xml file, similar to how a DataSource is configured?
You can use deployment descriptors to override settings made by annotations.
Maybe you can inject the values from outside, declaring a class similar to that what is described here:
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/twbs_devwbsjaxwsclient_dyn.html

Categories