我终于找到了办法。您可以通过创建一个模拟soap引擎来实现这一点,该引擎返回您想要的xml。然后axis将完成所有的解析和所有的逻辑,就像它是从http源获得的一样。下面是一个例子:
public class SimulatorHandler extends BasicHandler
{
/**
* System property to that hold soap response message in xml.
*/
private static final String responseMsg = "soapResponse";
/**
* @return the responseMsg
*/
public static String getResponseMsgSystemProperty()
{
return responseMsg;
}
public void invoke(MessageContext context) throws AxisFault
{
// i haven't figure out a way to do a setter on this msg
// so I have to get it from system properties
String msg = System.getProperty(responseMsg);
ByteArrayInputStream is = new ByteArrayInputStream(msg.getBytes());
Message response = new Message(is);
response.setMessageType(Message.RESPONSE);
context.setResponseMessage(response);
}
}