Hi again!

As far as I know, Web Services are basically XML messages that are exchanged via a http connection. That's why objects have to serialized before they can be send over the network. So basically your service puts information into the header and sends it to the client, which in turn can read the information stored in the header.
I found an example on the ibm website:
http://www-106.ibm.com/developerworks/xml/library/x-tipsoap.html


Hope this helps,
Tom

Plorks mail wrote:


Hi,

A littlle question

I have my java file with some methods in it

validateUser
externalWSMethod

and some others .....

When a client comes in they go to the validateUser method and it is here i need to create a soapheader to insert a value.

What i'm confused about is does the client create a header or do i do it from the server-side ws? Does it matter who creates it?

If i insert a value into the header how do i keep checkng it?

It's the logic i'm getting stuck with i think

Many thanks for your help






From: Tom Ziemer <[EMAIL PROTECTED]>
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:45:23 +0200

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 <[EMAIL PROTECTED]>
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 <[EMAIL PROTECTED]>
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



_________________________________________________________________
Want to block unwanted pop-ups? Download the free MSN Toolbar now! http://toolbar.msn.co.uk/


Reply via email to