Tuesday, July 17, 2007

How to inject xml fragments into Netbeans BPEL Editor

Some JBI components, such as the RSS Binding Component, require specific inputs that are complex types verses simple types like xsd:string. For example when wishing to subscribe to multiple feeds at one time you need to specify an EndpointReferenceList which extends the WS-Addressing schema.

One way to populate this list is to use the UDDI Binding Component, which returns an EndpointReferenceList containing multiple addresses. However, if you want something simpler without the burden of setting up a UDDI Server ,you can also use a BPEL String literal to specify XML fragments directly in a BPEL Process using Netbeans/OpenESB.

The key is to use the Source View verses the Design View because is not currently supported in the Design View (I am using Netbeans 6.0 20070622). After creating a new BPEL Module, process, and adding a sequence, go ahead and view the process in the Source View. Now a typical Assignment in BPEL looks like the following:

<variables>
<bpws:variable name="queryUddiOut" messageType="ns1:queryUddiOutReply"/>
<bpws:variable name="rssSubscribeIn" messageType="ns2:rssSubscribeInRequest"/>
</variables>

<sequence>
.........
<bpws:assign name="BasicAssign">
<bpws:copy>
<bpws:from variable="queryUddiOut" part="part1"/>
<bpws:to variable="rssSubscribeIn" part="part1"/>
</bpws:copy>
</bpws:assign>
.........
<sequence>

This next example should be exciting as it shows how to assign an XML fragment to a variable (which can next be used as input to an invocation) using a String literal:
<bpws:assign name="AssignXmlFragment">
<bpws:copy>
<bpws:from>
<bpws:literal>
<wsa:EndpointReference>
<wsa:Address>http://localhost:18181/stockQuoteService/stockQuotePort</wsa:Address>
<wsa:ServiceName PortName="stockQuotePort">
{http://j2ee.netbeans.org/wsdl/stockQuote}stockQuoteService
</wsa:ServiceName>
</wsa:EndpointReference>
</bpws:literal>
</bpws:from>
<bpws:to>$EPRVariable/wsa:EndpointReference</bpws:to>
</bpws:copy>
</bpws:assign>

The goal of this entry was to quickly explain how you can use the BPEL editor in Source View to assign XML fragments for whatever purpose you may require. Obviously it's not the best long-term solution because this is no different than hardcoding file paths in a java program. But is very useful for quick testing.

0 comments: