Tuesday, October 15, 2013

Mule - piggybacking SOAP calls in flows

I needed to handle session Cookie between connection calls and later data calls all in SOAP. I did this by using the same global HTTP connector with cookie enabled and using it on all the endpoints.

The connection call was in the first flow which then called the next ... that solves the Session handling without any coding, but i got mimetype/transformer exception on the 'return' / response path.

Errors like:
Could not find a transformer to transform "SimpleDataType{type=org.apache.cxf.staxutils.DepthXMLStreamReader, mimeType='text/xml'}" to "SimpleDataType{type=java.io.InputStream, mimeType='*/*'}".

The easy solution turned out to be saving the first SOAP response, calling the data flows with their own SOAP, and after the flow call, restoring the SOAP response.

...
<set-variable variableName="connectionUpPayload" value="#[message.payload]" doc:name="save response"/>
<flow-ref name="GetAllProperties" doc:name="GetAllProperties"/>
<set-payload value="#[flowVars['connectionUpPayload']]" doc:name="Set Payload"/>

...

Wednesday, October 9, 2013

Mule - Sharepoint Connector

I have been working a little with Mule ESB - Enterprise Edition. I needed to get a Sharepoint (duh - Imperial Star Battlecruisers), so I was happy to see the Mule Sharepoint Connector. The Connector implementents NTLMv2, so it can talk to newer Sharepoint versions. After getting past the first small gotchas (remember slash af URL, URL without the '_vti_bin' stuff, ListName is the list name & view name is the GUID) - the list was received as an SOAP Java object - GetListItemsResult.

Now that was perfect except the M$ SOAP service limits the result to 100 rows, if you do not specify a rowlimit, and i could not get that to work on the Sharepoint Connector component, so i 'just' made a java component from trial and error reverse engineering the component using the Java classes:

import org.mule.modules.sharepoint.SharepointConnector;
import org.mule.modules.sharepoint.microsoft.lists.GetListItems;
import org.mule.modules.sharepoint.microsoft.lists.GetListItemsResponse.GetListItemsResult;

....
SharepointConnector sc = new org.mule.modules.sharepoint.SharepointConnector();
             sc.connect("DOMAIN\\USERNAME", "PASSWORD", "URL_W_SLASH");

org.mule.modules.sharepoint.microsoft.lists.GetListItems request =
            new org.mule.modules.sharepoint.microsoft.lists.GetListItems();
request.setListName("LISTNAME");
request.setRowLimit("" + 0);
request.setViewName("VIEW_GUID");
GetListItemsResult result = sc.listGetListItems(request);


Replace UPPERCASE names with real values. You can use the GetListAndView to get the GUIDs

Other ways of getting this to work is http://dmdaa.wordpress.com/2012/10/10/ntlm-v2-support-for-java-web-service-clients-wsimport-or-axis2-stubs-for-sharepoint-server/

However I did not succeed with that approach.