Here is a primer on how to invoke SOAP web services from Infor M3 Enterprise Collaborator (MEC) using the Send Web Service process, where MEC is the SOAP client calling SOAP servers.
MEC process
I am using MEC version 11.4.3.
We find the Send Web Service process in Partner Admin > Agreement > Processes:
The properties are the following:
The MEC Partner Admin Tool User Guide does not have much information:
The MEC training workbook does not have information either.
I decompiled MEC and found the Java class com.intentia.ec.server.process.SendWebServiceProcess. I was expecting it to use a legitimate SOAP client such as Apache CXF, but it uses a mere java.net.HttpURLConnection:
Consequently, this process does no more than the HTTPOut process albeit the additional SOAP action property.
Problems
There are many problems with this type of implementation:
- It does not validate the message against the web service’s WSDL, the XML Schemas, not even against XML syntax
- It does not have a factory to create client stubs
- It is byte-based (we could send whatever content) whereas SOAP clients are more RPC-like with setters and getters for parameters
- It is HTTP-centric, not SOAP-centric
- It is restricted to HTTP whereas SOAP is agnostic to the underlying transport protocol, e.g. SOAP supports FTP
- It does not support WS-Security for XML Encryption and XML Signature
- It does not support the use of HTTP proxy
- Etcetera
Anyway, let’s give it a try.
Sample web service
I have a sample web service from TMW SystemsLink, a Transportation Management Software. It is available on my customer’s network. It is only setup for HTTP (not HTTPS), without authentication, thus it is insecure, but it is easy for illustration purposes.
First, I ensure I can get to the WSDL:
Test with SoapUI
Then, I test the web service with a SOAP client such as SoapUI:
Then, I get the SOAP action and content type to be used later (we can get them from the WS-A and http log tabs of SoapUI or from Fiddler):
Test with Java – optional
Optionally, I test the web service with the URLConnection in Java, from the same location and JRE as MEC:
javac Test.java && java -cp . Test
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; class Test { public static void main(String[] args) throws Exception { URL url = new URL("http://tmwsl/TMWSystemsLink/APIWCFServices.svc"); URLConnection con = url.openConnection(); con.setDoOutput(true); con.setRequestProperty("Content-Type", "text/xml;charset=UTF-8"); con.setRequestProperty("SOAPAction", "http://tempuri.org/IAPIWCFServices/RetrieveCarrier"); String data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\" xmlns:tmw=\"http://schemas.datacontract.org/2004/07/TMWSystems.SystemsLink.APIClasses\"><soapenv:Header/><soapenv:Body><tem:RetrieveCarrier><tem:criteria><tmw:CarrierID>JONCOL</tmw:CarrierID></tem:criteria></tem:RetrieveCarrier></soapenv:Body></soapenv:Envelope>"; con.setRequestProperty("Content-Length", "" + data.length()); OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream()); out.write(data); out.close(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String s; while ((s = in.readLine()) != null) { System.out.println(s); } in.close(); } }
The result is the SOAP response:
Test in Partner Admin
Now, I am ready to test in Partner Admin. I create a simple test agreement with the Send Web Service process configured to the end point address, content type, and SOAP action:
Then, I add a simple detection such as the default DiskIn, I reload the communication channel in the MEC Grid Management Pages, I create a file with the sample SOAP request, I drop the file in the DiskIn folder, I wait for MEC to process the file, and I check the result; the usual steps in MEC.
Result
Here is the result in MEC Grid Management Pages, it successfully finished sending the SOAP request, and getting the SOAP response:
Here is the resulting POST HTTP request:
At this point we can use Partner Admin and MEC Mapper to transform an M3 MBM and generate the SOAP request, we can process the SOAP response, etc.
Conclusion
That was an illustration of how to call SOAP web services from Infor M3 Enterprise Collaborator (MEC) using the Send Web Service process, for MEC to be a SOAP client calling SOAP servers. Despite “Web Service” in its name, the process is deceitfully not very SOAP oriented, but we can manage with it.
Future work
In future posts I will:
- Explore how to securely call a web service over HTTPS (not HTTP); if I use a custom server certificate, I have to setup the JRE keystore, or explore the Partner Admin > Manage > Certificate Keystores:
- Explore how to use the Partner Admin > Manage > Web Service Definitions; I do not know what this is for:
- Explore how to use the Manage > Advanced > WebServiceSyncIn/Out; I think that is for MEC to be a SOAP server, accept requests, and serve responses:
That’s it.
Please leave a comment, click Like, click Follow to subscribe, share around you, and come write the next blog post.
Hi Thibaud. Have you found anything interesting on this SOAP web service? I investigated a bit this topic a few months ago for our UK branch which asked me to use the shipping API from Royal Mail (forwarder agent in UK). I quickly gave up and surrendered; it requires a nonce, a password digest… which is not possible at the time being. The simple http request seams to work but i don’t know how to receive the response from the server (for example, GlobalWeather.wsdl allow you to retrieve weather in San Francisco 😉 ).
LikeLike
I’ll take a look. What’s the URL? I don’t see it. In parallel, I am working on securely calling web services from MEC, using XML-Encryption and XML-Signature; maybe that’s what you mean. Also, I sent you an important email to your Yahoo, please read it.
LikeLike
You could be referring to HTTP Basic Digest Access Authentication (supported by the Infor Grid Router authentication methods), or to WSSE (deprecated) the pre-OASIS version of WS-Security (supported for MEC’s WebServiceSyncIn; must developed for MEC’s SendWebService).
LikeLike
NOTE: Also, SendWebServiceProcess does not support setting custom HTTP request headers.
LikeLike
Hi,
I have a solution to develop where I need to call ecb exchange rate API in MEC.
And take the response from API and update in m3 via MEC
Can you please help me in understanding which solution approach is good
LikeLike