1

I'm almost sure nobody here will be able to help me. But I'm desperated. This is part of my final work on bachelors degree and I can't get it to work.

I wrote a code in Java and this code submits a string to a server ( maintained by a lab in my university which provides this service), it processes my data and replies with the new data that I want.

All works fine, except for one thing.. Sometimes I need to submit strings with ISO-8859-1 characters ( like "é" or "ã" ) and those characters get to the server all messed up.

My problem is that the whole submission data process is made with WSDL/RMI and I know nothing about how it works.

I just followed a wizard on Eclipse and it created a class that has the methods that I want (imported from the server). When I call the one I want it prepares my string and send it to the server through an apache call object.

I really don't know what I should do to fix it. I tried setting the encoding of the call object using :

_call.setEncodingStyle("ISO-8859-1");

But no success.

Here is the code of the method that does the call.

public int runTask(java.lang.String userName, java.lang.String password, java.lang.String language, java.lang.String linguisticInfo, java.lang.String inText) throws java.rmi.RemoteException 
    {
        if (super.cachedEndpoint == null) {
            throw new org.apache.axis.NoEndPointException();
        }
        org.apache.axis.client.Call _call = createCall();
        _call.setOperation(_operations[1]);
        _call.setUseSOAPAction(true);
        _call.setSOAPActionURI("");
        _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
        _call.setOperationName(new javax.xml.namespace.QName("http://fextwswrapper", "runTask"));

        setRequestHeaders(_call);
        setAttachments(_call);
 try {        java.lang.Object _resp = _call.invoke(new java.lang.Object[] {userName, password, language, linguisticInfo, inText});

        if (_resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException)_resp;
        }
        else {
            extractAttachments(_call);
            try {
                return ((java.lang.Integer) _resp).intValue();
            } catch (java.lang.Exception _exception) {
                return ((java.lang.Integer) org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
            }
        }
  } catch (org.apache.axis.AxisFault axisFaultException) {
  throw axisFaultException;
}
    }

If someone could explain me what is happening or a fix it. I would extremely appreciate.

Thanks a lot!

Roiw
  • 147
  • 2
  • 16
  • what you meant by those characters get to the server all messed . give some input and output – Mani Apr 30 '14 at 20:23
  • I dont have access to the server. But for a right "é" character it should reply to me a 'V' and for every other character it should reply me a 'N'. And its replying a 'N'. – Roiw Apr 30 '14 at 20:32

1 Answers1

1

you need to use UTF-8 encoding for data you are sending

by default ASCII will read only 8bits for a char while special characters like those which you are sending takes more memory and hence the text shows up as ?

dev2d
  • 4,245
  • 3
  • 31
  • 54
  • Do you know how I can set the encoding of an apache call? `_call.setEncodingStyle("UTF8");` is not working. – Roiw Apr 30 '14 at 20:36
  • you need to encode data, rather than encoding some request! you can refer http://stackoverflow.com/questions/5729806/encode-string-to-utf-8 for encoding string to UTF-8 – dev2d Apr 30 '14 at 20:39
  • I mean suppose you have special chars in userName, encode userName to UTF-8 and send – dev2d Apr 30 '14 at 20:40
  • going to try that! Will reply here if it works ! Thanks! – Roiw Apr 30 '14 at 20:40
  • In that link says that strings have UTF-16 encoding and it can't be modified. The string that I am sending with the special character is inText. When I debug the code it looks ok right after the invoke method. ( If a inspect the variable it looks ok) I think it messes right before that. – Roiw Apr 30 '14 at 20:48