You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Paul Jones <pj...@novell.com> on 2004/12/20 19:25:52 UTC
getting a parameter
Hello,
I am fairly new to axis so I may be missing something very obvious, but
I can not get the values of the parameters passed to our webservice from
the MessageContext. I am writing an Authorization piece to the service
and need to know what the value of the first parameter is to verify that
the user can actually make this call.
I have tried to go about this in a couple of ways so far.
msgContext.getOperation().getParameter(0) returns a ParameterDesc which
tells me everything about the Parameter except the value. This was
somewhat helpful in that I could see the name of the parameter so I know
I am getting the correct one. I can not figure out a way to get the
value of the parameter using this information though.
RPCElement reqRPC =
(RPCElement)msgContext.getRequestMessage().getSOAPEnvelope().getFirstBody();
RPCParam p = reqRPC.getParam(arg0);
The above two lines give me the actual parameter as far as I can tell.
performing a println on p shows me that I have the correct parameter
again. The output is:
<arg0 soapenc:arrayType=soapenc:string[1] xsi:type=soapenc:Array
xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance>
<item xsi:type=soapenc:string>com.novell.supplychain.Item</item>
</arg0>
The value of item is what I am trying to get
(com.novell.supplychain.Item). Calling p.item(0) returns null.
Am I going the right direction or is there an easier/better way to get
the value of the parameter?
Any help would be very appreciated.
Paul Jones
Re: getting a parameter
Posted by av...@allesta.com.
Hi Paul,
This should get you where you want to go....
SOAPEnvelope env = messageContext.getRequestMessage().getSOAPEnvelope();
SOAPBodyElement e = env.getFirstBody();
Iterator it = e.getChildElements();
while (it.hasNext()) {
}
By iterating thru the child elements you should be able to retrieve the proper
information...
Al
Quoting Paul Jones <pj...@novell.com>:
> Hello,
>
> I am fairly new to axis so I may be missing something very obvious, but
> I can not get the values of the parameters passed to our webservice from
> the MessageContext. I am writing an Authorization piece to the service
> and need to know what the value of the first parameter is to verify that
> the user can actually make this call.
>
> I have tried to go about this in a couple of ways so far.
>
> msgContext.getOperation().getParameter(0) returns a ParameterDesc which
> tells me everything about the Parameter except the value. This was
> somewhat helpful in that I could see the name of the parameter so I know
> I am getting the correct one. I can not figure out a way to get the
> value of the parameter using this information though.
>
> RPCElement reqRPC =
> (RPCElement)msgContext.getRequestMessage().getSOAPEnvelope().getFirstBody();
>
> RPCParam p = reqRPC.getParam(arg0);
> The above two lines give me the actual parameter as far as I can tell.
> performing a println on p shows me that I have the correct parameter
> again. The output is:
> <arg0 soapenc:arrayType=soapenc:string[1] xsi:type=soapenc:Array
> xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/
> xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance>
> <item xsi:type=soapenc:string>com.novell.supplychain.Item</item>
> </arg0>
>
> The value of item is what I am trying to get
> (com.novell.supplychain.Item). Calling p.item(0) returns null.
>
> Am I going the right direction or is there an easier/better way to get
> the value of the parameter?
>
> Any help would be very appreciated.
>
> Paul Jones
>
>