axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Ziemer <t.zie...@dkfz-heidelberg.de>
Subject Re: invoke methods wsdl file
Date Wed, 04 May 2005 09:45:23 GMT
Hi,

here is what I did, to access the MessageContext:

// invoke the call
...
// then:
MessageContext mx = call.getMessageContext();
Message m = mx.getCurrentMessage();


I am not sure how to access the header information, but you could try this:
m.getSOAPHeader().getAttribute("someAttribute");

Hope this helps,

Regards,
Tom

Plorks mail wrote:
> 
> 
> Hi
> 
> Thanks for the explanation
> 
> I guess now i need to carry on with the next stage.
> 
> I need to read a header value, so need to pass the soap context 
> (MessageContext)
> 
> Can you show me how to do this?  Is it soemthing like this
> 
> Many thnaks for your time and help
> 
> 
> public getHeaderValue(MessageContext msgcontext)
> {
> Message message = msgContext.getRequestMessage();
> SOAPEnvelope requestEnvelope = message.getSOAPEnvelope();
> SOAPHeaderElement headerElement = 
> requestEnvelope.getHeaderByName("http://domain","HeaderName");
> 
>            if (headerElement != null)
>            {
>                String headerElementValue = 
> (String)headerElement.getValue();   (or getValueAsType)
>            }
> 
> 
> 
> 
> 
> }
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>> From: Tom Ziemer <t.ziemer@dkfz-heidelberg.de>
>> Reply-To: axis-user@ws.apache.org
>> To: axis-user@ws.apache.org
>> Subject: Re: invoke methods wsdl file
>> Date: Wed, 04 May 2005 11:05:27 +0200
>>
>> Hi,
>>
>> ---
>> call.setOperationName("someMethod");
>> String ret = (String) call.invoke( new Object[] { new Integer(6) } );
>> ---
>>
>> First you set the operation name, that is, the service's method you 
>> want to call then you excute the method (call.invoke()). The 
>> parameters for the service are passed as an array, so basically that's 
>> a rather complicated way of calling:
>>
>> service.someMethod(new Integer(6));
>>
>> The service in turn returns a String, which you have to cast, since 
>> invoke() only returns an java.lang.Object.
>>
>> I'm not sure what you mean by "carry on". At this point the client has 
>> called the service and a result was returned so basically the 
>> transaction is finished. What else do you want to do?
>>
>> Reagrds,
>> Tom
>>
>>
>> Plorks mail wrote:
>>
>>>
>>> Hi
>>>
>>> Can you explain the lline
>>>
>>>
>>> String txt = (String) call.invoke(new Object[] { new Integer(6) });
>>>
>>>
>>> How o  carry on the code after this line
>>>
>>> Sorry for my newbiee questions
>>>
>>>
>>>
>>>> From: Tom Ziemer <t.ziemer@dkfz-heidelberg.de>
>>>> Reply-To: axis-user@ws.apache.org
>>>> To: axis-user@ws.apache.org
>>>> Subject: Re: invoke methods wsdl file
>>>> Date: Tue, 03 May 2005 14:27:07 +0200
>>>>
>>>> Hi there!
>>>>
>>>> You could let ANT (using the axis-tasks) generate the necessary stub 
>>>> files. In my opinion that is a much cleaner approach. Then you 
>>>> simply call the service as if it were a local object:
>>>>
>>>> // the locator is generated by axis/ant...
>>>> someLocator locator = new someLocator();
>>>> // ...the service object as well
>>>> someService service = null;
>>>> try
>>>> {
>>>>   // get a reference
>>>>   someService = somelocator.getSomeService();
>>>>   // call the service
>>>>   String msg = someService.someMethod();
>>>>   ...
>>>> }
>>>> ...
>>>>
>>>> If you want to do it the other way:
>>>>
>>>> String endpoint = "http://xxx/someService";
>>>> Service service = new Service();
>>>> Call call = (Call) service.createCall();
>>>> call.setTargetEndpointAddress(new java.net.URL(endpoint));
>>>> // define operation (method)
>>>> call.setOperationName("methodToCall");
>>>> // call the service
>>>> String txt = (String) call.invoke(new Object[] { new Integer(6) });
>>>> ...
>>>>
>>>> As I said - I prefer the former way. Hope this helps you to get 
>>>> started.
>>>>
>>>> Regards,
>>>> Tom
>>>>
>>>> Plorks mail wrote:
>>>>
>>>>>
>>>>> Hello
>>>>>
>>>>> I've got to develop a web service client, but don't know where to 
>>>>> start
>>>>>
>>>>> I have the external wsdl file which exposes the methods i wish to 
>>>>> invoke.
>>>>>
>>>>> Is it something like this
>>>>>
>>>>> public static void main(String args[])
>>>>> {
>>>>> URL url = new 
>>>>> URL("http://thirdpartycallservice/third_party_calling_service.wsdl");
>>>>> Service service = new Service();
>>>>> Call call = (Call)service.createCall();
>>>>> .
>>>>> .
>>>>> .
>>>>> .
>>>>> .
>>>>> .
>>>>> }
>>>>>
>>>>> I don't know the next code to continue
>>>>>
>>>>> Any help much appreciated
>>>>>
>>>>> _________________________________________________________________
>>>>> Be the first to hear what's new at MSN - sign up to our free 
>>>>> newsletters! http://www.msn.co.uk/newsletters
>>>>>
>>>
>>> _________________________________________________________________
>>> Want to block unwanted pop-ups? Download the free MSN Toolbar now!  
>>> http://toolbar.msn.co.uk/
>>>
> 
> _________________________________________________________________
> Be the first to hear what's new at MSN - sign up to our free 
> newsletters! http://www.msn.co.uk/newsletters
> 

Mime
View raw message