I managed to do it by copy/pasting some code from org.apache.axis.client.Call.

It wasn't easy, but it involved creating a new Message object, setting it's char encoding to "ISO-8859-1", and then assembling the envelope to send to Call.

Then to deal with the response, the code needed to get the body element, and extract the RPCParams from it.

As a newcomer to Axis, this was a good learning experience, and I am getting a better feel for how all this works. No need to comment on the details of my lack of error checking, etc, but I wouldn't mind finding a simpler way to do this.

Here is my new much longer snippet of how I made the call in ISO-8859-1.

// before this code runs, these are set: namespace, method, xml, endpoint, document

        Call    call    = (Call) service.createCall();
        call.setTargetEndpointAddress( new java.net.URL( endpoint ) );
        call.setOperationName( new QName( namespace, method ) );

        MessageContext msgContext = call.getMessageContext();
        SOAPEnvelope  env = null ;
        env = new SOAPEnvelope(msgContext.getSOAPConstants(),
                                   msgContext.getSchemaVersion());

RPCParam param = new RPCParam(namespace, method, xml);
RPCElement body = new RPCElement(namespace, method, new Object[] { param });
env.addBodyElement((SOAPBodyElement) body);
Message msg = new Message( env );
msg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "ISO-8859-1");
call.setRequestMessage(msg);
call.invoke();
msg = msgContext.getResponseMessage();
if (msg == null) {
if (msgContext.isPropertyTrue(Call.FAULT_ON_NO_RESPONSE, false)) {
System.out.println("Axis Fault");
} else {
System.out.println("Error");
}
}
env = msg.getSOAPEnvelope();
SOAPBodyElement bodyEl = env.getFirstBody();
if (bodyEl instanceof RPCElement) {
Vector resArgs = null ;
try {
resArgs = ((RPCElement) bodyEl).getParams();
} catch (Exception e) {
System.out.println("Error making resArgs: "+e);
}
if (resArgs != null && resArgs.size() > 0) {


                for (int i = 0; i < resArgs.size(); i++) {
                    RPCParam p1 = (RPCParam) resArgs.get(i);
                    Object value = p1.getObjectValue();
                    if (value instanceof Document) {
                        document = (Document)value;
                    }
                }
            }
        }



On Nov 17, 2004, at 12:39 PM, Peuclid wrote:
So, just to start, I'm trying to get my test client to request the data in ISO-8859-1 just to see what happens when I change the global "axis.xmlEncoding" to ISO-8859-1. So far, that doesn't seem to be changing the default anywhere. Looking at the AxisServlet code, I see that the encoding is set by the request.

So, now I need to figure out how to set the encoding of the request.



Reply via email to