Accessing Soap service using java adapter in mobil

2019-09-03 07:55发布

问题:

I have written a SOAP WSDL application using mobilefirst by:

1) Using the Discover backend services option

2) Writing my own JavaScript adapter code to follow the documentation provided by IBM.

Now my final R&D is to consume this soap service using a java adapter.

I have gone through many StackOverflow topics and samples but I haven't been able to find anything related. Can anyone explain the steps to invoke a SOAP-based webservice request using java adapter?

回答1:

The following video blog post details the following about Java adapers: https://www.youtube.com/watch?v=cKM5480-6wI

  1. Creating Java Adapter
  2. Understanding Java Adapter structure
  3. Implementing simple sayHello procedure for HTTP GET method
  4. Implementing several procedures for different HTTP methods
  5. Working with various types of request parameters
  6. Using Java code to access MobileFirst server functionality and Java servlet functionality
  7. Debugging Java Adapters
  8. Communicating with a simple backend using using Apache HTTP Client
  9. Leveraging WSDL files and communicating with a SOAP based webservice
  10. Using WLResourceRequest in client applications to communicate with Java Adapters
  11. Using Postman REST client for communicating with Java Adapters


回答2:

  1. Create HTTP Adapter
  2. In xml add WebService Host and Port in Domain/Port elements
  3. Assemble soapXMLRequest
  4. Use HTTP Invoke to call server

ex.

var input = {
    method : 'post',
    returnedContentType : 'xml',
    headers : {
        SOAPAction : SOAP_FULL_URL
    },
    path : WEBSERVICE_PATH,
    body : {
        content : soapXMLRequest,
        contentType : 'text/xml; charset=utf-8'
    }
};
var response = WL.Server.invokeHttp(input);