Topic
4 replies Latest Post - ‏2013-01-19T21:19:01Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts
ACCEPTED ANSWER

Pinned topic Adapter Calling Webservice failed

‏2013-01-14T07:00:47Z |
Hi,

I am trying to call a java code that is basically calling a webservice. Because I was facing issues in directly calling Webservice via Adapter.
Now the code works fine when running directly through java Main class. But when i access a it via public statis method via Adapter i get following exception.
"errors": [
"Runtime: invocation of javascript function 'callEnquiry' has failed: tried to access class org.apache.commons.logging.LogFactory$1 from class org.apache.commons.logging.LogFactory"
]
i have provided all necessary Log files and it works fine through java main method.

any idea or suggestion?

thanks
  • SystemAdmin
    SystemAdmin
    2327 Posts
    ACCEPTED ANSWER

    Re: Adapter Calling Webservice failed

    ‏2013-01-14T15:50:55Z  in response to SystemAdmin
    Can you post the adapter code used to make the invocation?
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: Adapter Calling Webservice failed

      ‏2013-01-17T07:18:01Z  in response to SystemAdmin
      Hi,

      Let me explain it here what i want to do.

      I have created few webservices in java and now wants to consume them via Adapters. All services run fine via a java client application.

      So when making call via adapters it fails with below error message.
      "errors": [
      "The markup in the document following the root element must be well-formed.",
      "Failed to parse the payload from backend (procedure: HttpRequest)"
      ],
      "info": [
      ],
      "isSuccessful": false,
      "responseHeaders": {
      "Content-Length": "131",
      "Content-Type": "text\/html;charset=utf-8",
      "Date": "Thu, 17 Jan 2013 07:17:23 GMT",
      "Server": "Apache-Coyote\/1.1"
      },
      "statusCode": 200,
      "statusReason": "OK",
      "warnings": [
      ]
      I am attaching one sample Webservice (Provider part) and below is my Adapter code calling this service.


      adapter xml
      <displayName>callWSTest</displayName>
      <description>callWSTest</description>
      <connectivity>
      <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
      <protocol>http</protocol>
      <domain>localhost</domain>
      <port>8081</port>
      </connectionPolicy>
      <loadConstraints maxConcurrentConnectionsPerNode="2" />
      </connectivity>

      <procedure name="callEnquiry"/>


      adapter JS
      function callEnquiry() {
      var interest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://enquiry.rc.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
      '<soapenv:Body>'+
      '<q0:enquiry>'+
      '<q0:customerName>test</q0:customerName> '+
      ' <q0:cardNo>test</q0:cardNo> '+
      ' <q0:email>test</q0:email> '+
      ' <q0:phoneNo>test</q0:phoneNo> '+
      ' <q0:mrStatus>test</q0:mrStatus> '+
      ' <q0:countryOfOrigin>test</q0:countryOfOrigin> '+
      ' <q0:countryOfResidence>test</q0:countryOfResidence> '+
      ' <q0:date>test</q0:date> '+
      ' </q0:enquiry>'+
      ' </soapenv:Body>'+
      '</soapenv:Envelope>';
      var input = {
      method : 'get',
      returnedContentType : 'xml',
      path : '/EnquiryServer/services/Enquiry',
      body: {
      content: interest.toString(),
      contentType: 'text/xml; charset=utf-8'

      }
      };
      return WL.Server.invokeHttp(input);

      }

      -------------------------

      I have deployed Provider part (attached file) on the local tomcat v7. JDK 7, Win-7, WL Studio 5.0.5

      thanks
      Abdul Ahad
      • SystemAdmin
        SystemAdmin
        2327 Posts
        ACCEPTED ANSWER

        Re: Adapter Calling Webservice failed

        ‏2013-01-17T16:15:02Z  in response to SystemAdmin
        Thank you for posting your source code. I ran your program on tomcat and was able to reproduce your problem. When the adapter is invoked, you have specified that you are expecting xml to be returned:

        
        var input = 
        { method : 
        'get', returnedContentType : 
        'xml', path : 
        '/EnquiryServer/services/Enquiry', body: 
        { content: interest.toString(), contentType: 
        'text/xml; charset=utf-8' 
        }
        


        However, the returned value from doing a 'get' to the path /EnquiryServer/services/Enquiry is not xml, which is why you are getting the error:

        "The markup in the document following the root element must be well-formed.",
        "Failed to parse the payload from backend (procedure: HttpRequest)"

        When the adapter call returns, it tries to parse the result as xml. Since the result is not valid xml, it complains.

        If you change the returnedcontenttype to 'plain' or 'html', then your adapter call works properly:

        
        var input = 
        { method : 
        'get', returnedContentType : 
        'plain', path : 
        '/EnquiryServer/services/Enquiry', body: 
        { content: interest.toString(), contentType: 
        'text/xml; charset=utf-8' 
        }
        
        • SystemAdmin
          SystemAdmin
          2327 Posts
          ACCEPTED ANSWER

          Re: Adapter Calling Webservice failed

          ‏2013-01-19T21:19:01Z  in response to SystemAdmin
          Hi,

          Yes i re-tried it again but it is NOT returning value (result) but it is just saying that service call has been made successfully ... in other words, it successfully did handshake with server and returned back.

          isSuccessful=true is always being returned when handshake is done.....but it does not guarantee of returned data.
          Thanks
          Abdul Ahad