Fusion Middleware Software like OSB or SOA Suite is not yet available on WebLogic 12c but this does not mean you can't develop SCA Applications. With the help of the Oracle Enterprise for Eclipse 12.1.1 ( OEPE ) we can build WebLogic SCA application and deploy it on WebLogic 12c. This allows you to write Java applications using POJOs and, through different protocols, expose components as SCA services and access other components via references. You do this using SCA semantics configured in a Spring application context. In SCA terms, a WebLogic Spring SCA application is a collection of POJOs plus a Spring SCA context file that wires the classes together with SCA services and references.
In this blogpost I will show you all the steps so you can try it yourself.
Before we start, we need to install WebLogic 12c, configure a new domain and startup the AdminServer.
The first step is to install the WebLogic SCA shared library and target it to the AdminServer.
Log in to the WebLogic Console and go to deployments windows.
Install this war located at wlserver_12. 1\common\deployable-libraries\weblogic-sca-1.1.war as a shared library and target it to the AdminServer.
Next step is to download OEPE 12.1.1, extract it and create a new workspace.
In this workspace we need to create a new Dynamic Web Project.
Use wls 12 as Target runtime and also create an Ear project which will include the war.
Open the project options of your Dynamic Web Project and go to Project Facets.
Here we need to enable Oracle WebLogic SCA and Spring.
Click on Further configuration required.
Next step is to download the Spring library. Click on the download button and select Spring Framework 2.5.6 of Oracle.
Click on Next.
We need to add the WebLogic SCA Shared Library, this will be added to the weblogic.xml deployment descriptor of your Web Project.
You can open the weblogic.xml file of your Web project and in the Shared Libraries you should see the reference.
When you are in the Web Perspective then you can open the spring-context.xml in the beans section of the Spring Elements.
Or in the java perspective this is located in the jsca folder of the META-INF folder.
In the Spring-context.xml we will add some spring beans which have an EJB & Web Service SCA service and we also add some SCA references.
In this demo I will start with a SCA service with has a ws binding , this service has a target to a spring bean. This spring has a property to a SCA reference which an EJB binding.
The SCA reference calls a SCA Service which off course also has an EJB binding. The service target the next spring bean which the calls the last spring bean.
We start with the last spring bean and end with the first SCA service.
This the LoggerOutput class which just do a system out.
Because we want to expose the next spring bean as a SCA service we need to have an interface which we can use in the SCA service.
And now the implementation which calls the last spring bean LoggerOutput
Now we have everything to make our first SCA application. This is how the spring-context will look like.
This SCA service will be invoked in the second part of this blogpost where we will call this EJB from a web service.
We can use the same ILoggerComponent interface for the SCA Service ( this time a web service ) and the SCA reference will call the already created EJB SCA service.
We only need a new spring bean which pass on the message to the EJB. For this I use this LoggerPassThrough class.
Here is the total spring-context.xml
We are ready to deploy it and do a test run. Select your EAR project, right click and do run on Server.
Provide the details of your WebLogic 12c domain.
You can use soapUI to invoke the SCA Web Service http://localhost:7001/WebLogicSCA/LoggerService_Uri?WSDL
or invoke the SCA EJB Service
ILoggerComponent logEJB = (ILoggerComponent)context.lookup("LoggerService_EJB30_JNDI");
WebLogic also has an extension for WebLogic SCA , in the Console , go to the Preferences , Extensions and enable weblogic-sca-console. You need to restart your WebLogic Server.
After this you can click on your SCA deployment and see your SCA Services and references.
Download the code at github
https://github.com/biemond/OEPE_examples/tree/master/wls12cSCA
Showing posts with label SCA. Show all posts
Showing posts with label SCA. Show all posts
Sunday, December 18, 2011
Monday, December 14, 2009
SCA Spring in Weblogic 10.3.2 & Soa Suite 11g Part 2
In my previous post I made a SCA Spring example and deployed this on Weblogic 10.3.2 Now it is time to use the same spring context and java sources in a Soa Suite 11g composite ( without any changes) . Keep in mind SCA Spring in WLS and the Spring Component in Soa Suite is still in preview and will be supported in Patch Set2 of Soa Suite 11g.
In this example I use the java Logger and BPEL component of Clemens OTN article.
First I copied the java sources from my Weblogic SCA Spring project to the Soa project and created for demo purposes two Spring Bean configurations.
The first has a bean with a service and a reference and the second one has only a bean with a service. ( Off course I can combine these two together in one spring bean configuration, but this is more fun)
The first spring bean configuration will just passthrough the java call. We need to remove the WS and EJB binding in the service and reference. ( Soa Suite don't need this )
The second spring bean configuration is the java logger. Here we also have to remove the WS binding in the service
Now the composite application looks like this. We need to add some wires between the BPEL and Spring Components.


Open the BPEL component and add an invoke to call the partnerlink and create the input and output variables.

Deploy the composite and test it in the Soa Suite. With this as result.
Conclusion: With the new SoaSuite Spring component it is relative easy to do a java call outs and you can exchange your SCA spring application from Weblogic to Soa Suite without any changes.
Here is my Soa Suite example workspace
In this example I use the java Logger and BPEL component of Clemens OTN article.
First I copied the java sources from my Weblogic SCA Spring project to the Soa project and created for demo purposes two Spring Bean configurations.

The first spring bean configuration will just passthrough the java call. We need to remove the WS and EJB binding in the service and reference. ( Soa Suite don't need this )
<?xml version="1.0" encoding="windows-1252" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca">
<!--Spring 2.5 Bean defintions go here-->
<sca:service target="loggerPassThrough" name="LogServiceWS"
type="nl.whitehorses.wls.sca.spring.ILoggerComponent">
</sca:service>
<bean class="nl.whitehorses.wls.sca.spring.LoggerPassThrough" name="loggerPassThrough">
<property name="reference" ref="loggerEJBReference" />
</bean>
<sca:reference name="loggerEJBReference"
type="nl.whitehorses.wls.sca.spring.ILoggerComponent">
</sca:reference>
</beans>
The second spring bean configuration is the java logger. Here we also have to remove the WS binding in the service
<?xml version="1.0" encoding="windows-1252" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca">
<!--Spring 2.5 Bean defintions go here-->
<sca:service target="logger" name="LogServiceEJB"
type="nl.whitehorses.wls.sca.spring.ILoggerComponent">
</sca:service>
<bean class="nl.whitehorses.wls.sca.spring.LoggerComponentImpl" name="logger">
<property name="output" ref="loggerOutput" />
</bean>
<bean id="loggerOutput" class="nl.whitehorses.wls.sca.spring.LoggerOutput"></bean>
</beans>
Now the composite application looks like this. We need to add some wires between the BPEL and Spring Components.


Open the BPEL component and add an invoke to call the partnerlink and create the input and output variables.

Deploy the composite and test it in the Soa Suite. With this as result.

Here is my Soa Suite example workspace
Sunday, December 13, 2009
SCA Spring in Weblogic 10.3.2 & Soa Suite 11g
With Weblogic 10.3.2 ( part of Patch Set 1 of Fusion Middleware R1 ) Oracle released a preview of SCA Spring. For more info about this announcement see the blog of Raghav.
This is great news because everything what works in SCA Spring can be used without any problem in Soa Suite 11g. With Patch Set 2 SCA Spring will be supported in WLS or Soa Suite. For a Soa Suite Spring example see this blog of Clemens
To test this I made a small example based on the blog of Clemens. In this test I will call a logging webservice and this service will pass the call to a passthrough bean which has a reference to an logging EJB service which calls a logging bean and this bean has an other bean injected which does the output.
First deploy the weblogic-sca war as a library to the WLS server, you can find this war in wlserver_10.3/common/deployable-libraries/ folder and is called weblogic-sca-1.0.war
Create in JDeveloper a new web project ( no need for ADF ) . We don't need the spring jar or add some config in the web.xml ( this can be empty , don't need to add spring listener )
Add a library reference in your webapp to the weblogic-sca library, Do this in the weblogic.xml or weblogic-application.xml file
Create a spring from jdeveloper and call this file spring-context.xml and put this in META-INF/jsca folder ( in the src folder )
When you got experience with Apache Tuscany then this spring configuration is not so difficult.
Now we need to create a logger interface, this will be use by the WS & EJB services and references.
Create a passthrough class this will pass on the logger call to the ejb service.
Create the logger implementation class.
The last class prints the console output
Deploy the web application the weblogic server and use soapui to test the service. The wsdl url is in my case http://laptopedwin.wh.lan:7001/WlsSpring-ScaSpring-context-root/LoggerService_Uri?WSDL or make a EJB test client and use this ILoggerComponent logger = (ILoggerComponent)context.lookup("LoggerService_EJB30_JNDI");
Here you can download my code on github https://github.com/biemond/jdev11g_examples/tree/master/WlsSpring
This is great news because everything what works in SCA Spring can be used without any problem in Soa Suite 11g. With Patch Set 2 SCA Spring will be supported in WLS or Soa Suite. For a Soa Suite Spring example see this blog of Clemens
To test this I made a small example based on the blog of Clemens. In this test I will call a logging webservice and this service will pass the call to a passthrough bean which has a reference to an logging EJB service which calls a logging bean and this bean has an other bean injected which does the output.
First deploy the weblogic-sca war as a library to the WLS server, you can find this war in wlserver_10.3/common/deployable-libraries/ folder and is called weblogic-sca-1.0.war
Create in JDeveloper a new web project ( no need for ADF ) . We don't need the spring jar or add some config in the web.xml ( this can be empty , don't need to add spring listener )
Add a library reference in your webapp to the weblogic-sca library, Do this in the weblogic.xml or weblogic-application.xml file
<?xml version = '1.0' encoding = 'windows-1252'?> <weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd" xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"> <library-ref> <library-name>weblogic-sca</library-name> </library-ref> </weblogic-web-app>
Create a spring from jdeveloper and call this file spring-context.xml and put this in META-INF/jsca folder ( in the src folder )
When you got experience with Apache Tuscany then this spring configuration is not so difficult.
<?xml version="1.0" encoding="windows-1252" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sca="http://xmlns.oracle.com/weblogic/weblogic-sca" xmlns:wlsb="http://xmlns.oracle.com/weblogic/weblogic-sca-binding" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://xmlns.oracle.com/weblogic/weblogic-sca http://xmlns.oracle.com/weblogic/weblogic-sca/1.0/weblogic-sca.xsd http://xmlns.oracle.com/weblogic/weblogic-sca-binding http://xmlns.oracle.com/weblogic/weblogic-sca-binding/1.0/weblogic-sca-binding.xsd"> <!--Spring 2.5 Bean defintions go here--> <sca:service target="loggerPassThrough" name="LogServiceWS" type="nl.whitehorses.wls.sca.spring.ILoggerComponent"> <wlsb:binding.ws xmlns="http://xmlns.oracle.com/sca/1.0" name="LoggerService_WS" uri="/LoggerService_Uri" port="LoggerService_PORT"/> </sca:service> <sca:reference name="loggerEJBReference" type="nl.whitehorses.wls.sca.spring.ILoggerComponent"> <wlsb:binding.ejb uri="LoggerService_EJB30_JNDI" /> </sca:reference> <bean class="nl.whitehorses.wls.sca.spring.LoggerPassThrough" name="loggerPassThrough"> <property name="reference" ref="loggerEJBReference" /> </bean> <sca:service target="logger" name="LogServiceEJB" type="nl.whitehorses.wls.sca.spring.ILoggerComponent"> <wlsb:binding.ejb uri="LoggerService_EJB30_JNDI" remote="true" name="LoggerService_EJB"/> </sca:service> <bean class="nl.whitehorses.wls.sca.spring.LoggerComponentImpl" name="logger"> <property name="output" ref="loggerOutput" /> </bean> <bean id="loggerOutput" class="nl.whitehorses.wls.sca.spring.LoggerOutput"></bean> </beans>
Now we need to create a logger interface, this will be use by the WS & EJB services and references.
package nl.whitehorses.wls.sca.spring; public interface ILoggerComponent { /** * Log a message, including the originating component, its instance id and * a message. * @param pComponentName the name of the component that sends this log msg * @param pInstanceId the instanceId of the component instance * @param pMessage the message to be logged */ public void log (String pComponentName, String pInstanceId, String pMessage); }
Create a passthrough class this will pass on the logger call to the ejb service.
package nl.whitehorses.wls.sca.spring; public class LoggerPassThrough implements ILoggerComponent { public LoggerPassThrough() { super(); } @Override public void log(String pComponentName, String pInstanceId, String pMessage) { reference.log(pComponentName, pInstanceId, pMessage); } private ILoggerComponent reference; public void setReference(ILoggerComponent reference) { this.reference = reference; } public ILoggerComponent getReference() { return reference; } }
Create the logger implementation class.
package nl.whitehorses.wls.sca.spring; public class LoggerComponentImpl implements ILoggerComponent { public LoggerComponentImpl() { super(); } @Override public void log(String pComponentName, String pInstanceId, String pMessage) { output.logToConsole(pComponentName, pInstanceId, pMessage); } private LoggerOutput output; public void setOutput(LoggerOutput output) { this.output = output; } public LoggerOutput getOutput() { return output; } }
The last class prints the console output
package nl.whitehorses.wls.sca.spring; public class LoggerOutput { public LoggerOutput() { super(); } public void logToConsole(String pComponentName, String pInstanceId, String pMessage) { StringBuffer logBuffer = new StringBuffer (); logBuffer.append("[").append(pComponentName).append("] [Instance: "). append(pInstanceId).append("] ").append(pMessage); System.out.println(logBuffer.toString()); } }
Deploy the web application the weblogic server and use soapui to test the service. The wsdl url is in my case http://laptopedwin.wh.lan:7001/WlsSpring-ScaSpring-context-root/LoggerService_Uri?WSDL or make a EJB test client and use this ILoggerComponent logger = (ILoggerComponent)context.lookup("LoggerService_EJB30_JNDI");
Here you can download my code on github https://github.com/biemond/jdev11g_examples/tree/master/WlsSpring
Tuesday, November 3, 2009
Working with Apache Tuscany, The Java SCA based platform part 1
In this blogpost and future blogposts I will try to give you a jumpstart with Apache Tuscany Java SCA. If you follow my blog you may already know that I also work and make blogsposts over an other Service Component Architecture (SCA)-based SOA platform ( Oracle Soa Suite 11g). Soa Suite 11g has a different SCA approach and has much better designer support. But it is nice to take a look at Tuscany and see how this java SCA implementation works.
I will explain how you can make some composite applications. In this blogpost we start easy with building a composite application with
Here a overview of my test project.

First we need to download Apache Tuscany Java SCA
We start with a simple java component with its interface.
We can add this component in the step1 composite file and provide the java implementation class.
Last part of step 1 is to run this composite application, now we have to load and test the composite application.
In step 2 we will call a jax-ws webservice. In this step we also need to add a reference to the component.
To make this work I created first a jax-ws service and deploy this to an application server.
In the tuscany client project we need to generate a webservice proxy client for this webservice.
Create an implemention class for this ws proxy client. In this class we need to add a reference with the name jaxws and a setter. We will use this in the composite xml
create a new composite file where we will add this component and its reference. In the reference we need to provide the web service binding
And at last the test client
In step 3 we will expose an component as a service. First step is to make an interface with the methods which we want to expose in this web service. We have to add Remotable annotation.
The implementatation of this component with the Service annotation and off course the references to the other components.
The step3 composite file has a TuscanyServiceComponent with 3 references to the step 1 and 2 components and this component has also a service. In this service we have to provide the ws url.
The client code which tests the main component and start the service on this component
Now we can use soapui to test this web service.

In the last step in this blog I will use a second composite which will be called by the first composite.
First we create a new composite xml. We will copy a java component from the step3 composite to this composite. Give this composite a new name and target namespace. We will use these values to import this composite. This component needs a service else we can not call it from the main composite.
The main composite called step4_1 need the namespace of the second composite. The JavaCp2 component import the second composite by using the target namespace of the second composite and with its name. In the javaComponent2 reference of the TuscanyServiceComponent will call JavaCp2 component followed by the service name of the second composite.
and at last the step 4 test client.
Here you can download my jdeveloper 11G test project.
I will explain how you can make some composite applications. In this blogpost we start easy with building a composite application with
- Simple java Component
- Jax-ws component
- Component with references to other components ( wires )
- Service on a component
- Using a second composite
Here a overview of my test project.

First we need to download Apache Tuscany Java SCA
We start with a simple java component with its interface.
package nl.whitehorses.tuscany.step1;
public interface JavaService {
public String getData();
}
package nl.whitehorses.tuscany.step1;
public class JavaServiceImpl implements JavaService {
public String getData() {
return "Hello from java component";
}
}
We can add this component in the step1 composite file and provide the java implementation class.
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://whitehorses"
name="step1">
<component name="JavaCp">
<implementation.java class="nl.whitehorses.tuscany.step1.JavaServiceImpl" />
</component>
</composite>
Last part of step 1 is to run this composite application, now we have to load and test the composite application.
package nl.whitehorses.tuscany.step1;
import org.apache.tuscany.sca.host.embedded.SCADomain;
public class ClientStep1 {
public final static void main(String[] args) throws Exception {
SCADomain scaDomain = SCADomain.newInstance("step1.composite");
JavaService javaService = scaDomain.getService(JavaService.class, "JavaCp");
System.out.println("java: " + javaService.getData());
scaDomain.close();
}
}
In step 2 we will call a jax-ws webservice. In this step we also need to add a reference to the component.
To make this work I created first a jax-ws service and deploy this to an application server.
package nl.whitehorses.soa.ws;
import javax.jws.WebService;
@WebService
public class Helloworld {
public String getResponse( String message){
return message;
}
}
In the tuscany client project we need to generate a webservice proxy client for this webservice.
Create an implemention class for this ws proxy client. In this class we need to add a reference with the name jaxws and a setter. We will use this in the composite xml
package nl.whitehorses.tuscany.step2;
import nl.whitehorses.soa.ws.proxy.Helloworld;
import org.osoa.sca.annotations.Reference;
public class HelloworldServiceImpl implements Helloworld{
private Helloworld jaxws;
@Reference
public void setJaxws(Helloworld jaxws) {
this.jaxws = jaxws;
}
public String getResponse( String message){
return jaxws.getResponse(message);
}
}
create a new composite file where we will add this component and its reference. In the reference we need to provide the web service binding
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://whitehorses"
name="step2">
<component name="HelloworldCp">
<implementation.java class="nl.whitehorses.tuscany.step2.HelloworldServiceImpl" />
<reference name="jaxws">
<binding.ws wsdlElement="http://ws.soa.whitehorses.nl/#wsdl.port(HelloworldService/HelloworldPort)"
uri="http://localhost:7101/jaxws/HelloworldPort?wsdl#wsdl.interface(HelloworldService)"/>
</reference>
</component>
</composite>
And at last the test client
package nl.whitehorses.tuscany.step2;
import org.apache.tuscany.sca.host.embedded.SCADomain;
import nl.whitehorses.soa.ws.proxy.Helloworld;
public class ClientStep2 {
public final static void main(String[] args) throws Exception {
SCADomain scaDomain = SCADomain.newInstance("step2.composite");
Helloworld helloworld = scaDomain.getService(Helloworld.class, "HelloworldCp");
System.out.println("ws: " + helloworld.getResponse("hello"));
scaDomain.close();
}
}
In step 3 we will expose an component as a service. First step is to make an interface with the methods which we want to expose in this web service. We have to add Remotable annotation.
package nl.whitehorses.tuscany.step3;
import org.osoa.sca.annotations.Remotable;
@Remotable
public interface TuscanyService {
public String getJaxwsResponse( String message);
public String getJavaData();
public String getJavaData2();
}
The implementatation of this component with the Service annotation and off course the references to the other components.
package nl.whitehorses.tuscany.step3;
import nl.whitehorses.soa.ws.proxy.Helloworld;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
import nl.whitehorses.tuscany.step1.JavaService;
@Service(TuscanyService.class)
public class TuscanyServiceImpl implements TuscanyService {
private Helloworld helloworldComponent;
private JavaService javaComponent;
private JavaService javaComponent2;
@Reference
public void setHelloworldComponent(Helloworld helloworldComponent) {
this.helloworldComponent = helloworldComponent;
}
@Reference
public void setJavaComponent(JavaService javaComponent) {
this.javaComponent = javaComponent;
}
@Reference
public void setJavaComponent2(JavaService javaComponent2) {
this.javaComponent2 = javaComponent2;
}
public String getJaxwsResponse(String message) {
return helloworldComponent.getResponse(message) ;
}
public String getJavaData() {
return javaComponent.getData();
}
public String getJavaData2() {
return javaComponent2.getData();
}
}
The step3 composite file has a TuscanyServiceComponent with 3 references to the step 1 and 2 components and this component has also a service. In this service we have to provide the ws url.
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://whitehorses"
name="step3">
<component name="TuscanyServiceComponent">
<implementation.java class="nl.whitehorses.tuscany.step3.TuscanyServiceImpl" />
<reference name="helloworldComponent" target="HelloworldCp" />
<reference name="javaComponent" target="JavaCp" />
<reference name="javaComponent2" target="JavaCp2" />
<service name="TuscanyService">
<binding.ws uri="http://localhost:8085/TuscanyService"/>
</service>
</component>
<component name="JavaCp">
<implementation.java class="nl.whitehorses.tuscany.step1.JavaServiceImpl" />
</component>
<component name="JavaCp2">
<implementation.java class="nl.whitehorses.tuscany.step1.JavaServiceImpl" />
</component>
<component name="HelloworldCp">
<implementation.java class="nl.whitehorses.tuscany.step2.HelloworldServiceImpl" />
<reference name="jaxws">
<binding.ws wsdlElement="http://ws.soa.whitehorses.nl/#wsdl.port(HelloworldService/HelloworldPort)"
uri="http://localhost:7101/jaxws/HelloworldPort?wsdl#wsdl.interface(HelloworldService)"/>
</reference>
</component>
</composite>
The client code which tests the main component and start the service on this component
package nl.whitehorses.tuscany.step3;
import java.io.IOException;
import org.apache.tuscany.sca.host.embedded.SCADomain;
public class ClientStep3 {
public final static void main(String[] args) throws Exception {
SCADomain scaDomain = SCADomain.newInstance("step3.composite");
TuscanyService tuscanyService = scaDomain.getService(TuscanyService.class, "TuscanyServiceComponent");
System.out.println("ws: "+tuscanyService.getJaxwsResponse("hello"));
System.out.println("java: "+tuscanyService.getJavaData());
System.out.println("java2: "+tuscanyService.getJavaData2());
try {
System.out.println("ws service started (press enter to shutdown)");
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
scaDomain.close();
}
}
Now we can use soapui to test this web service.

In the last step in this blog I will use a second composite which will be called by the first composite.
First we create a new composite xml. We will copy a java component from the step3 composite to this composite. Give this composite a new name and target namespace. We will use these values to import this composite. This component needs a service else we can not call it from the main composite.
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://whitehorses2"
name="step4_2">
<service name="JavaCpService" promote="JavaCp">
<interface.java interface="nl.whitehorses.tuscany.step1.JavaService"/>
</service>
<component name="JavaCp">
<implementation.java class="nl.whitehorses.tuscany.step1.JavaServiceImpl" />
</component>
</composite>
The main composite called step4_1 need the namespace of the second composite. The JavaCp2 component import the second composite by using the target namespace of the second composite and with its name. In the javaComponent2 reference of the TuscanyServiceComponent will call JavaCp2 component followed by the service name of the second composite.
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://whitehorses"
xmlns:whitehorses2="http://whitehorses2"
name="step4_1">
<component name="TuscanyServiceComponent">
<implementation.java class="nl.whitehorses.tuscany.step3.TuscanyServiceImpl" />
<reference name="helloworldComponent" target="HelloworldCp" />
<reference name="javaComponent" target="JavaCp" />
<reference name="javaComponent2" target="JavaCp2/JavaCpService" />
<service name="TuscanyService">
<binding.ws uri="http://localhost:8085/TuscanyService"/>
</service>
</component>
<component name="JavaCp">
<implementation.java class="nl.whitehorses.tuscany.step1.JavaServiceImpl" />
</component>
<component name="HelloworldCp">
<implementation.java class="nl.whitehorses.tuscany.step2.HelloworldServiceImpl" />
<reference name="jaxws">
<binding.ws wsdlElement="http://ws.soa.whitehorses.nl/#wsdl.port(HelloworldService/HelloworldPort)"
uri="http://localhost:7101/jaxws/HelloworldPort?wsdl#wsdl.interface(HelloworldService)"/>
</reference>
</component>
<component name="JavaCp2">
<implementation.composite name="whitehorses2:step4_2"/>
</component>
</composite>
and at last the step 4 test client.
package nl.whitehorses.tuscany.step4;
import nl.whitehorses.tuscany.step3.TuscanyService;
import java.io.IOException;
import org.apache.tuscany.sca.host.embedded.SCADomain;
public class ClientStep4 {
public final static void main(String[] args) throws Exception {
SCADomain scaDomain = SCADomain.newInstance("step4_1.composite");
TuscanyService tuscanyService = scaDomain.getService(TuscanyService.class, "TuscanyServiceComponent");
System.out.println("ws: "+tuscanyService.getJaxwsResponse("hello"));
System.out.println("java: "+tuscanyService.getJavaData());
System.out.println("java2: "+tuscanyService.getJavaData2());
try {
System.out.println("ws service started (press enter to shutdown)");
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
scaDomain.close();
}
}
Here you can download my jdeveloper 11G test project.
Subscribe to:
Posts (Atom)