Skip to Content

soap supports Multipart WSDL’s,In multipart WSDL files, an implementation WSDL file contains the wsdl:service. This implementation WSDL file imports an interface WSDL file, which contains the other WSDL constructs. This supports multiple Web services using the same WSDL interface definition.

in this page we will look in to handle the multipart wsdl using custom script.

Steps from Design Time tool

  1. Create an OData Service Implementation Project
  2. Create an OData Model Corresponding to the WSDL parameters.

MultiPART1.jpg

    3. Right click on odatasvc and choose Select data source

    4. Select the entity set and choose the query CRUD operation. Select the data source SOAP Service.

Img2.jpg

    5. Specify the wsdl file and choose the appropriate operation from the list of soap operations and click on finish

Img3.jpg

    6. Right click on Query and select Define Custom Code

Img4.jpg

    7. Select the script type as either javascript or groovy script

    8. Here in our case the wsdl has Authentication, so we are retrieving the credentials from the request headers and passing it to cxf component as Input in the form of a HashMap.


function processRequestData(message) {
  importPackage(java.util);
  importPackage(org.apache.olingo.odata2.api.processor);
  var parentMap = new HashMap();
  var context = message.getHeaders().get("odatacontext");
  var username = context.getRequestHeaders().get("username").get(0);
  var password = context.getRequestHeaders().get("password").get(0);
  importPackage(com.sap.gateway.ip.core.customdev.logging);
  log.logErrors(LogMessage.TechnicalError, "user:" + username+"**");
  log.logErrors(LogMessage.TechnicalError, "password:" + password+"**");
  var childMap = new HashMap();
  childMap.put("user_name", username);
  childMap.put("password", password);
  parentMap.put("user_auth", childMap);
  message.setBody(parentMap);
  return message;
}

    9. Once the web service response is returned, the response has to be parsed to get the corresponding entities and convert the same to an xml format and set it to exchange body.


function processResponseXML(message) {
  importPackage(java.util);
  importPackage(java.lang);
  var payload = message.getBody().toString();
  importPackage(com.sap.gateway.ip.core.customdev.logging);
  log.logErrors(LogMessage.TechnicalError, "Response Payload is: " + payload);
  var tokens = payload.split("(?=<)|(?<=>)");
  var buffer = new StringBuffer();
  buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  buffer.append("<LoginRequestSet><LoginRequest>");
  var breakLoop = false;
  for(var i=0;i<tokens.length;i++)
  {
  if(tokens[i].contains("id") && !breakLoop)
  {
  buffer.append("<id>");
  buffer.append(tokens[i+1]);
  buffer.append("</id>");
  i=i+2;
  breakLoop = true;
  }
  if(tokens[i].contains("module_name"))
  {
  buffer.append("<module_name>");
  buffer.append(tokens[i+1]);
  buffer.append("</module_name>");
  i=i+2;
  }
  }
  buffer.append("</LoginRequest></LoginRequestSet>");
  message.setBody(buffer.toString());
  return message;
}

    10. Right Click on Project and select Generate and Deploy Integration Content. This will deploy the bundle.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply