[
https://issues.apache.org/jira/browse/AXIS2-2264?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12477306
]
Federica Ciotti commented on AXIS2-2264:
----------------------------------------
Thanks for helping Deepal.
Now I'm facing a new AxisFault exception I get when I try to access one of the
two serviceGroupContext properties on my service group, the two properties are
an Integer and a FindResult custom object.
This is my service class
public class AddService {
//messageContext vars
MessageContext inmsgContext = null;
MessageContext outmsgContext = null;
//logger vars
private static Logger logger = Logger.getLogger("calc");
private static FileHandler fh;
public AddService()
{
try {
fh = new
FileHandler("/home/faith/workspace/CalculatorService/addServicelog.txt");
}catch(IOException e) {}
logger.addHandler(fh);
logger.setLevel(Level.ALL);
initMsgCtx();
}
private void initMsgCtx()
{
MessageContext msgCtx = MessageContext.getCurrentMessageContext();
OperationContext opCtx = msgCtx.getOperationContext();
try {
inmsgContext = opCtx.getMessageContext("In");
outmsgContext = opCtx.getMessageContext("Out");
} catch (AxisFault e) {e.printStackTrace();}
if (inmsgContext==null)
{
logger.info("IN message Context is null");
}
if (outmsgContext==null)
{
logger.info("OUT message Context is null");
}
}
public Integer add(Integer p1, Integer p2) {
EndpointReference myEPR = new
EndpointReference("http://localhost:8080/axis2/services/AddService/");
int param1 = p1.intValue();
int param2 = p2.intValue();
int result = param1 + param2;
//set CALCULATOR_PREVIOUS_KEY
Integer res = new Integer (result);
inmsgContext.getServiceGroupContext().setProperty(Constants.CALCULATOR_PREVIOUS_KEY,
res);
//test only
Integer previousStr = (Integer)
inmsgContext.getServiceGroupContext().getProperty(Constants.CALCULATOR_PREVIOUS_KEY);
logger.info("context number is: "+previousStr.intValue());
//set FIND_RESULT
FindResult f = new FindResult();
f.setString(1, "hello");
inmsgContext.getServiceGroupContext().setProperty(Constants.FIND_RESULT, f);
//test only
FindResult t = (FindResult)
inmsgContext.getServiceGroupContext().getProperty(Constants.FIND_RESULT);
ArrayList list = t.getList();
logger.info("find result[0]: "+(String)list.get(0));
logger.info("find result[1]: "+(String)list.get(1));
//test only
logger.info("add: getSoapAction"+inmsgContext.getSoapAction());
return res;
}
Changing the order of setProperty, getProperty in thsi way:
set CALCULATOR_PREVIOUS_KEY
set FIND_RESULT
get FIND_RESULT
getCALCULATOR_PREVIOUS_KEY
I get a AxisFault and a ClassCastException on the server side .
I'm wondering if I must call the setProperty and getProperty for the same
property in this order, that's way I get ClassCastException if I set my first
property and try to get my second property.
The code you suggested for the message Context is fine but I can't get service
side addressing field yet...
Even if I do:
Options s = new Options();
s.setFrom(myEPR);
outmsgContext.setOptions(s);
in my service method, the soap:Header element is still empty: <soapenv:Header
/>.
> "org.apache.axis2.AxisFault: Incoming message input stream is null" while
> engaging addressing module on client side
> -------------------------------------------------------------------------------------------------------------------
>
> Key: AXIS2-2264
> URL: https://issues.apache.org/jira/browse/AXIS2-2264
> Project: Axis 2.0 (Axis2)
> Issue Type: Bug
> Components: Addressing
> Affects Versions: 1.1.1
> Environment: Linux Fedora fc5, tomcat 6.0.7, java1.5.0_11, Axis2 1.1.1
> Reporter: Federica Ciotti
> Attachments: AddService.java, Constants.java, MultiplyService.java,
> newCalc.aar
>
>
> My client class needs to engage addressing module.
> This is my client
> package calc1;
> public class RPC_MyCalcClient {
> public static void main(String[] args){
> try{
> EndpointReference targetEPR = new
> EndpointReference("http://localhost:8080/axis2/services/AddService/");
> EndpointReference myEPR = new
> EndpointReference("http://localhost:8080/axis2/services/clientService/");
> Options options = new Options();
> options.setTo(targetEPR);
> options.setReplyTo(myEPR);
> options.setFrom(myEPR);
> //options.setAction("addPrevious");
> options.setAction("add");
> options.setFrom(myEPR);
> options.setMessageId("Msg123");
>
> RPCServiceClient sender = new RPCServiceClient();
> sender.setOptions(options);
> sender.engageModule(new
> QName(Constants.MODULE_ADDRESSING));
> //add
> QName opAdd = new QName("http://calc/xsd", "add");
> Integer a = new Integer(1);
> Integer b = new Integer(2);
> Object[] params = new Object[] { a, b };
> Class[] returnTypes = new Class[] { Integer.class };
> Object[] response = sender.invokeBlocking(opAdd,
> params, returnTypes);
> Integer result = (Integer) response[0];
> if (result == null) {System.out.println("Null");}
> else System.out.println("Result "+ result.toString());
>
> //addPrev
> /*QName opAdd = new QName("http://calc/xsd",
> "addPrevious");
> Integer a = new Integer(1);
> Object[] params = new Object[] { a};
> Class[] returnTypes = new Class[] { Integer.class };
> Object[] response = sender.invokeBlocking(opAdd,
> params, returnTypes);
> Integer result = (Integer) response[0];
> if (result == null) {System.out.println("Null");}
> else System.out.println("Result "+ result.toString());*/
> }catch(AxisFault a){a.printStackTrace();}
> }
> }
> Even if the addressing module is in the classpath I get AxisFault.
> This is the exception i get trying to engage addressing module on client side
> org.apache.axis2.AxisFault: Incoming message input stream is null
> at
> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:64)
> at
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:252)
> at
> org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:202)
> at
> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:579)
> at
> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
> at
> org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:95)
> at calc1.RPC_MyCalcClient.main(RPC_MyCalcClient.java:52)
> I noticed from SOAPMonitor that apart the AxisFault the request and response
> messages are correct but only the request one has the wsa header fields:
> SOAPRequest
> <?xml version='1.0' encoding='utf-8'?>
> <soapenv:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing"
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Header>
> <wsa:To>http://localhost:8080/axis2/services/AddService/</wsa:To>
> <wsa:ReplyTo>
>
> <wsa:Address>http://localhost:8080/axis2/services/clientService/</wsa:Address>
> </wsa:ReplyTo>
> <wsa:From>
>
> <wsa:Address>http://localhost:8080/axis2/services/clientService/</wsa:Address>
> </wsa:From>
> <wsa:MessageID>Msg123</wsa:MessageID>
> <wsa:Action>add</wsa:Action>
> </soapenv:Header>
> <soapenv:Body>
> <add xmlns="http://calc/xsd">
> <arg0 xmlns="">1</arg0>
> <arg1 xmlns="">2</arg1>
> </add>
> </soapenv:Body>
> </soapenv:Envelope>
> SOAPResponse
> <?xml version='1.0' encoding='utf-8'?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Header />
> <soapenv:Body>
> <ns:addResponse xmlns:ns="http://calc/xsd">
> <ns:return>3</ns:return>
> </ns:addResponse>
> </soapenv:Body>
> </soapenv:Envelope>
> How can I get wsa fields in the SOAPResponse (addressing module is already
> engaged on service side and is the classpath) ?
> Dropping the engage instruction from the client code causes the exception to
> disappear but I have a wsaddressing=required in the services.xml.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]