Consuming a Java Web Service (JWS) Method Containing String Arrays as Parameters

Consuming a Java Web Service (JWS) Method Containing String Arrays as Parameters

Recently I was working on a POC where one of the tasks was integrating with a Quality Control application that exposed a web service built with Java. The application used a JWS to expose web service methods that were RPC encoded. BizTalk Server 2006 and Visual Studio 2005 natively recognized and imported the JWS WSDL and generated a multi-part message in the BizTalk project.

Early in the POC, consuming, connecting and executing the process were demonstrated using a JWS method called, Sample Log. There was no issues importing the JWS WSDL but the challenge was populating the message since it used string arrays for parameter names and values.

Multi-part Message Types
The multi-part message type generated by importing the SampleLog WSDL are the last invoke_request and invoke_response in the figure below. We will take a closer look at the invoke_request message because the fieldsArrayC and valuesArray C items for the invoke_request message are actually string arrays. This message structure presents a challenge for BizTalk because although this message type was successfully generated in BizTalk, it was not available for use within the Mapper.


Using and populating the message structure
In order to use and populate the mutli-part message in BizTalk, 3 three messages needed to be defined to get around the limitations of the mapper.
These are:

  1. msgLIMSSampleLogRequest - Message that will be sent to the JWS.
  2. msgLogSampleReferenceNameArray – An array that contains the names of the parameters passed. This message structure will be added to the msgLIMSSampleLogRequest message.
  3. msgLogSampleReferenceValueArray – An array that contains the values of the parameters passed. This message structure will be added to the msgLIMSSampleLogRequest message.

    Create Message Variables

Orchestration Snippet
Because we can’t use the mapper, an orchestration must be used. In the orchestration, the msgLogSampleReferenceValueArray and msgLogSampleReferenceValueArray needed to be populated using the following code in the Expression Shape of the orchestration.

Once msgLogSampleReferenceValueArray and msgLogSampleReferenceValueArray messages were populated, they could be assigned to the msgLIMSSampleLogRequest message as described in the next section.

NOTE: This code is for demonstration purposes only. An actual implementation would use a component or other solution to populate the array depending on the requirements.

System.Diagnostics.Debug.WriteLine(System.String.Format("{0}{1}: {2}", strInterfaceName, "BuildReferenceArrays", ""));

//Format and Populate ReferenceName
strParameters = System.String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", "LOT", "LOT_NAME", "PRODUCT_GRADE", "DESCRIPTION", "ROLL", "SAMPLING_POINT", "SPEC_TYPE", "GROUP_NAME");
System.Diagnostics.Debug.WriteLine(System.String.Format("{0}{1}: {2}", "strParameters", "strParameters", strParameters));

objXmlDoc1 = new System.Xml.XmlDocument();
objXmlDoc1.LoadXml
(@"

LOT
LOT_NAME
PRODUCT_GRADE
DESCRIPTION
ROLL
SAMPLING_POINT
SPEC_TYPE
GROUP_NAME

"
);

msgLogSampleReferenceNameArray = objXmlDoc1;


System.Diagnostics.Debug.WriteLine(System.String.Format("{0}{1}: {2}", strInterfaceName, "ReferenceNameArray", objXmlDoc1.InnerXml));

//Format and Populate ReferenceValue
strParameters = System.String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", "89210", "1000222", "40786351", "S 901/ERL 1908 HM", "001", "6351ANYL", "SP_1", "WINONA");

objXmlDoc2 = new System.Xml.XmlDocument();
objXmlDoc2.LoadXml
(@"

89210
1000222
40786351
S 901/ERL 1908 HM
001
6351ANYL
SP_1
WINONA

"
);

msgLogSampleReferenceValueArray = objXmlDoc2;

System.Diagnostics.Debug.WriteLine(System.String.Format("{0}{1}: {2}", strInterfaceName, "ReferenceValueArray", objXmlDoc1.InnerXml));


Populate Main Message (LogRequest)
The final step is to populate the msgLIMSSampleLogRequest message in an Expression shape. Within the Expression shape the fieldsArrayC element is loaded with the msgLogSampleReferenceNameArray and the valuesArrayC element is loaded with the msgLogSampleReferenceValueArray.

The following is the code snippet that loads the message. The highlighted rows are where the string arrays from the previous step are actually loaded into the main message.

msgLIMSSampleLogRequest.authToken = msgLIMSAuthenticate1Response.authenticate1Result;
msgLIMSSampleLogRequest.templateNameC = "SPEC_IPL";
msgLIMSSampleLogRequest.fieldsArrayC = msgLogSampleReferenceNameArray;
msgLIMSSampleLogRequest.valuesArrayC = msgLogSampleReferenceValueArray;

No comments: