Topic
3 replies Latest Post - ‏2012-12-23T12:11:55Z by AntonAleksandrov
SystemAdmin
SystemAdmin
2327 Posts
ACCEPTED ANSWER

Pinned topic Adapter getting success in Worklight version 5.0.3 but failing in 5.0.5

‏2012-12-17T21:01:15Z |
Hi,

We are facing a problem while invoking an adapter in Worklight version 5.0.5. We used the same adapter code in Worklight version 5.0.3 and it is working fine. The same is giving a problem in the latest version.

Input : {
"body": {
"content": "{'abc':'def'}",
"contentType": "application/json"
},
"headers": {
"Accept": "application/json",
"Authorization": "Some token",
"Content-Type": "application/json"
},
"method": "put",
"path": "some path"
}
The error that we are getting in version 5.0.5 is :-

Response : {
"errors": [
],
"info": [
],
"isSuccessful": true,
"responseHeaders": {
"Connection": "close",
"Content-Length": "858",
"Content-Type": "text\/plain; charset=UTF-8",
"Date": "Mon, 17 Dec 2012 20:47:45 GMT",
"Vary": "Accept-Encoding",
"Via": "1.1 api.att.com"
},
"statusCode": 500,
"statusReason": "Internal Server Error",
"text": "<fault>\n <faultstring>JavaCalloutFailure<\/faultstring>\n <detail>\n <errorcode>34100<\/errorcode>\n <trace>\n Fault Name: JavaCalloutFailure\n Error Type: JavaCalloutFailure\n Description: JavaCalloutFailure\n Message: org.json.JSONException: A JSONObject text must begin with '{' at character 1\n Service: Payment\n Endpoint: MerchantPayment_client_v3.0\n Operation (Client):refundTransaction\n FlowTransitionState : Client_Request_User_Error\n Policy : JSONToXMLRefundTransactionPolicyR1\n ParseJSONRefundTransactionRequest\n <\/trace>\n <\/detail>\n<\/fault>",
"warnings": [
]
}
  • SystemAdmin
    SystemAdmin
    2327 Posts
    ACCEPTED ANSWER

    Re: Adapter getting success in Worklight version 5.0.3 but failing in 5.0.5

    ‏2012-12-18T00:50:41Z  in response to SystemAdmin
    Not sure if this will help, but here's something to try:

    Replace:

    
    
    "content": 
    "{'abc':'def'}",
    


    With:
    
    
    "content" : 
    "{\"abc\":\"def\"}",
    


    Why?

    
    JSON.parse( 
    "{'abc':'def'}"); 
    //what you have now SyntaxError: Unexpected token 
    '
    


    It doesn't seem to be valid JSON.

    However..

    
    JSON.parse( 
    "{\"abc\":\"def\"}" ); 
    //what I'm recommending \\ => Object: abc: 
    "def"
    


    Seems to be valid JSON.
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: Adapter getting success in Worklight version 5.0.3 but failing in 5.0.5

      ‏2012-12-18T23:45:38Z  in response to SystemAdmin
      Hi,

      Let me provide the exact input I am providing :

      Input : {
      "body": {
      "content": "{\n \"RefundReasonCode\": 1,\n \"RefundReasonText\": \"Customer was not happy\",\n \"TransactionOperationStatus\": \"Refunded\"\n}",
      "contentType": "application\/json"
      },
      "headers": {
      "Accept": "application\/json",
      "Authorization": "some code",
      "Content-Type": "application\/json"
      },
      "method": "put",
      "path": "some path"
      }

      NOTE that this input is working fine in Worklight 5.0.3 but not in 5.0.5.

      The error is :
      "statusCode": 500,
      "statusReason": "Internal Server Error",
      "text": "<fault>\n <faultstring>JavaCalloutFailure<\/faultstring>\n <detail>\n <errorcode>34100<\/errorcode>\n <trace>\n Fault Name: JavaCalloutFailure\n Error Type: JavaCalloutFailure\n Description: JavaCalloutFailure\n Message: org.json.JSONException: A JSONObject text must begin with '{' at character 1\n Service: Payment\n Endpoint: MerchantPayment_client_v3.0\n Operation (Client):refundTransaction\n FlowTransitionState : Client_Request_User_Error\n Policy : JSONToXMLRefundTransactionPolicyR1\n ParseJSONRefundTransactionRequest\n <\/trace>\n <\/detail>\n<\/fault>",

      If I change my content type to application/xml, my input looks like :

      Input : {
      "body": {
      "content": "<RefundTransactionRequest><TransactionOperationStatus>Refunded<\/TransactionOperationStatus><RefundReasonCode>1<\/RefundReasonCode><RefundReasonText>Customer was unhappy<\/RefundReasonText><\/RefundTransactionRequest>",
      "contentType": "application\/xml"
      },
      "headers": {
      "Accept": "application\/json",
      "Authorization": "Some code",
      "Content-Type": "application\/xml"
      },
      "method": "put",
      "path": "Some path"
      }

      The error again comes in worklight 5.0.5 as under :

      "statusCode": 500,
      "statusReason": "Internal Server Error",
      "text": "<fault>\n <faultstring>Error in Xpath ReEvaluation<\/faultstring>\n <detail>\n <errorcode>301902<\/errorcode>\n <trace>\n Fault Name: XpathReEvaluationFailure\n Error Type: XpathReEvaluationFailure\n Description: Error in Xpath ReEvaluation\n Root Cause Code: -18533\n Root Cause : XML Parser Error: Unexpected char while looking for open tag ('<') character\n Service: Payment\n Endpoint: MerchantPayment_client_v3.0\n Operation (Client):refundTransaction\n FlowTransitionState : Client_Request_User_Error\n Policy : JSONToXMLRefundTransactionPolicyR1\n xpathReEvaluate1\n <\/trace>\n <\/detail>\n<\/fault>",
      • AntonAleksandrov
        AntonAleksandrov
        55 Posts
        ACCEPTED ANSWER

        Re: Adapter getting success in Worklight version 5.0.3 but failing in 5.0.5

        ‏2012-12-23T12:11:55Z  in response to SystemAdmin
        According to the error message exception occurs at backend and not at Worklight. Backend returns status 500, which is internal server error.

        "statusCode": 500,
        "statusReason": "Internal Server Error",
        "text": "<fault>\n <faultstring>Error in Xpath ReEvaluation<\/faultstring>\n <detail>\n <errorcode>301902<\/errorcode>\n <trace>\n Fault Name: XpathReEvaluationFailure\n Error Type: XpathReEvaluationFailure\n Description: Error in Xpath ReEvaluation\n Root Cause Code: -18533\n Root Cause : XML Parser Error: Unexpected char while looking for open tag ('<'s hard to say what exactly backend expects without knowing more info about it. Is this something that is accessible on the internet so we can try?