Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ejb3 webservice url in weblogic

I have an EJB3 session bean annotated with @WebService(serviceName="MyServiceName", portName="MyPortName"). When it is deployed into Weblogic 11g the service endpoint is located at

host:port/BeanClassName/MyServiceName

Is it possible to change the service endpoint address of the webservice? i.e. to

host:port/my/context/root/something/MyServiceName

I tried to use the weblogic-webservices.xml deployment descriptor, but it requires the webservices.xml descriptor which requires a WSDL location element, but that should be generated by the server and the location of it differs in the dev and prod environments.

like image 344
pentike Avatar asked Jul 13 '11 17:07

pentike


1 Answers

Suppose you have an EJB

package com.example;
@Stateless
@WebService
OrganizationService {...}

First you should write a webservices.xml file for it as follows, since its sections will be referenced back from weblogic-webservices.xml where the actual endpoint configuration is done.

webservices.xml (Caution: by adding webservices.xml webservice annotations in classes are overridden!):

<?xml version="1.0" encoding="UTF-8"?>
<webservices xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2">
  <webservice-description>
  <!-- just a label, can be anything you want -->
  <webservice-description-name>MyServiceName</webservice-description-name>
  <port-component>
    <!-- just a label, can be anything you want -->
    <port-component-name>MyServicePort</port-component-name>
        <!-- Target namespace from wsdl -->
        <wsdl-port xmlns:ex="http://example.com/target/name/Space">ex:MyService</wsdl-port>
        <!-- Fully qualified class name of the ejb interface/bean providing the service -->
        <service-endpoint-interface>com.example.OrganizationService</service-endpoint-interface>
        <service-impl-bean>
        <!-- The class name of the bean providing the service -->
          <ejb-link>OrganizationService</ejb-link>
        </service-impl-bean>
    </port-component>
  </webservice-description>
</webservices>

Then in the weblogic-webservices.xml you can define whatever endpoint you want.

weblogic-webservices.xml:

<?xml version='1.0' encoding='UTF-8'?>
<weblogic-webservices xmlns="http://www.bea.com/ns/weblogic/weblogic-webservices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-webservices http://www.bea.com/ns/weblogic/weblogic-webservices/1.0/weblogic-webservices.xsd">
  <webservice-description>
  <!-- This must match the name given in webservices.xml -->
   <webservice-description-name>MyServiceName</webservice-description-name>
   <webservice-type>JAXWS</webservice-type>
    <port-component>
     <!-- This must match the name given in webservices.xml -->
      <port-component-name>MyServicePort</port-component-name>
      <service-endpoint-address>
        <webservice-contextpath>/myContextPath</webservice-contextpath>
        <webservice-serviceuri>/myServiceURI</webservice-serviceuri>
      </service-endpoint-address>
    </port-component>
  </webservice-description>
</weblogic-webservices>
like image 175
pentike Avatar answered Sep 23 '22 00:09

pentike