开发者

Mirth Connect: javascript to call a webservice

I'm trying to call a web service from a Mirth Channel transformer javascript using apache axis library (which it's supposed to be deployed with Mirth). I've tried using the following java script, but it does not work:

/*importPackage(java.net);
importPackage(org.apache.axis.client.Call);
importPackage(org.apache.axis.client.Service);
importP开发者_JAVA技巧ackage(javax.xml.namespace.QName);*/

  var endpoint = 'http://tempuri.org/IService1/';
  var service = org.apache.axis.client.Service();
  var call = service.createCall();
  call.setTargetEndpointAddress( new URL(endpoint) );
  call.setOperationName(new QName('http://soapinterop.org/', 'SayHello'));
  var ret = call.invoke('John Doe');

Any idea?

Thanks.


Answer:

  • Auto-generate service client proxy with Axis WDSL2Jave tool
  • Build a JAR archive with the auto-generated classes
  • Copy the JAR file in %MirthInstallPath%/lib/custom
  • Re-start Mirth service
  • Create a transformer JavaScript with the following code (in this example the WS is called Service1, a sample WS coded with .NET):
var locator = new Service1Locator();
var wsdlURL = new URL('http://localhost:8731/Design_Time_Addresses/HelloWorldWS/Service1'));
var proxy = locator.getBasicHttpBinding_IService1(wsdlURL);
var result = proxy.sayHello("John Doe");
// use result to whatever message mapping you need to perform

That's all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜