IBM BPM, V8.0.1, All platforms > Migrating and upgrading your IBM BPM environment > Migrating from other products > Migrating from WebSphere Studio Application Developer Integration Edition > Additional migration information > Create SCA Components and SCA Imports for the services in the application for rewiring > Migrating a Java service

Create the custom Java component: option 1

If the Migration wizard did not fully migrate all of your service projects, you can use the IBM Integration Designer Java Component type to represent the Java service as an SCA component. During migration, custom Java code must be written to convert between the SCA Java interface style and the existing Java component's interface style.

To create the custom Java component, follow these steps:

  1. Under the module project, expand Interfaces and select the WSDL interface that was generated for this Java class in WebSphere Studio Application Developer Integration.

  2. Drag this interface onto the Assembly Editor. A window will open asking you to select the type of component to create. Select Component with No Implementation Type and click OK.

  3. A generic component will appear on the Assembly diagram. Select it and go to the Properties view.

  4. On the Description tab, you can change the name and display name of the component to something more descriptive.

  5. On the Details tab you will see that this component has one interface - the one that you dragged onto the Assembly Editor.
  6. Ensure that the Java class that you are trying to access is on the classpath of the service project if it is not contained within the service project itself.
  7. Right-click the module project's Dependences and select Open. Under the Java, section ensure that the project containing the old Java class is listed. If it is not, add it by clicking Add….
  8. Back in the Assembly Editor, right-click the component that you just created and select Generate Implementation… > Java. Then select the package where the Java implementation will be generated. This creates a skeleton Java service that adheres to the WSDL interface according to the SCA programming model, where complex types are represented by an object that is a commonj.sdo.DataObject and simple types are represented by their Java Object equivalents.
The following code examples show:
  1. Relevant definitions from the 5.1 WSDL interface

  2. The WebSphere Studio Application Developer Integration Edition 5.1 Java methods that correspond to the WSDL

  3. The IBM Integration Designer Java methods for the same WSDL
The following code shows the relevant definitions from the 5.1 WSDL interface:
<types>
	<schema xmlns="http://www.w3.org/2001/XMLSchema" 
    			attributeFormDefault="qualified" 
    			elementFormDefault="unqualified"    
    			targetNamespace="http://migr.practice.ibm.com/" 
    			xmlns:xsd1="http://migr.practice.ibm.com/">

			<complexType name="StockInfo">
				<all>
					<element name="index" type="int"/>
					<element name="price" type="double"/>
					<element name="symbol" nillable="true" 
							    type="string"/>

				</all>
			</complexType>
	</schema>
</types>

<message name="getStockInfoRequest">
	<part name="symbol" type="xsd:string"/>
</message>
<message name="getStockInfoResponse">
	<part name="result" type="xsd1:StockInfo"/>
</message>

	<operation name="getStockInfo" parameterOrder="symbol">
			<input message="tns:getStockInfoRequest" 
							name="getStockInfoRequest"/>
			<output message="tns:getStockInfoResponse" 
 			 				name="getStockInfoResponse"/>
        </operation>
The following code shows the WebSphere Studio Application Developer Integration Edition 5.1 Java methods that correspond to the WSDL:
public StockInfo getStockInfo(String symbol)
	{
		return new StockInfo();
	} 
	public void setStockPrice(String symbol, float newPrice)
	{
		// set some things
	}
The following code shows the IBM Integration Designer Java methods for the same WSDL:
public DataObject getStockInfo(String aString) {
		//TODO Needs to be implemented.
		return null;
	} 
	public void setStockPrice(String symbol, Float newPrice) {
		//TODO Needs to be implemented.
	}
Now you will need to enter code where you see the “//TODO” tags in the generated Java implementation class. There are two options:
  1. Move the logic from the original Java class to this class, adapting it to use DataObjects.

    • This is the recommended option if you had chosen the top-down approach in WebSphere Studio Application Developer Integration Edition and want your Java component to deal with DataObject parameters. This rework is necessary because the Java classes generated from WSDL definitions in WebSphere Studio Application Developer Integration Edition have WSIF dependencies that should be eliminated.

  2. Create a private instance of the old Java class inside this generated Java class and write code to:
    1. Convert all parameters of the generated Java implementation class into parameters that the old Java class expects.

    2. Invoke the private instance of the old Java class with the converted parameters.
    3. Convert the return value of the old Java class into the return value type declared by the generated Java implementation method.

    This option is recommended for consumption scenarios where the WSIF service proxies must be consumed by new IBM Integration Designer style Java components.

Once you have completed one of these options, you must rewire the Java service. There should not be any references, therefore you just need to rewire the Java component's interface:

: Migrating a Java service