Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5575

ConverterUtil.convertToToken method can't handle String value with trailing spaces

    XMLWordPrintableJSON

Details

    Description

      I used wsdl2java.bat to generate client class from wsdl and xsd. The xsd contains token type elements.

      In my application, I used the client class to call the webservice and I got this error:

      org.apache.axis2.AxisFault: data=[ENG ]
      at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
      at com.example.MyWebServiceStub.fromOM(MyWebServiceStub.java:22807)
      ...
      Caused by: java.lang.IllegalArgumentException: data=[ENG ]
      at org.apache.axis2.databinding.types.Token.<init>(Token.java:47)
      at org.apache.axis2.databinding.utils.ConverterUtil.convertToToken(ConverterUtil.java:643)
      at com.example.MyWebServiceStub$Transaction$Factory.parse(MyWebServiceStub.java:9795)
      ...

      The error is in this line inside the MyWebServiceStub.java:

      object.setSecurityCode(org.apache.axis2.databinding.utils.ConverterUtil.convertToToken(content));

      The element value retrieved from webservice contains String value with trailing spaces ("ENG "). What I can understand is the class tried to convert the String value to Token for generating response, but since Token doesn't accept trailing spaces so that's why it throws error.

      Meanwhile, to fix this problem, I added trim() to the code:

      object.setSecurityCode(org.apache.axis2.databinding.utils.ConverterUtil.convertToToken(content.trim()));

      Attachments

        Activity

          People

            Unassigned Unassigned
            gogon Gogon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: