Wow!

Ok, I guess the solution to your problem will depend on where do you want to set the address. Could you elaborate a bit more?

Are you talking about the client-side or the server-side? I guess you are talking about the server response, but I am not sure.

Could you describe a bit your server deployment configuration? Do you have a single Axis webapp and you want to customize its behavior depending on the incoming network adapter, or you have separate webapps for each virtual-IP?

Regards,
Rodrigo

Carsten Schmidt wrote:
Hi,
oh, maybe we missunderstood each other.
There is no problem with the IP the service is running on.

On another machine a servlet is calling this service. For this call I
have to determine a special outgoing-IP, because it is a webserver on
which each webapp has it's own virtual-IP.

Only the IP from the app has the necessary permissions to pass the
firewall correctly.

By default the axis-call doesn't use the virtual-IP from the
webapp-context, but the IP from the server itself.

In detail:

Webserver with the IP 10.33.5.1
Virtual IP for the webapp 10.33.5.67

Carsten



Am Dienstag, den 16.05.2006, 09:47 +0200 schrieb Rodrigo Ruiz:
Ok,

If you look at the very first example in the users guide:

1 import org.apache.axis.client.Call; 2 import org.apache.axis.client.Service; 3 import javax.xml.namespace.QName; 4 5 public class TestClient { 6 public static void main(String [] args) { 7 try { 8 String endpoint = 9 "http://ws.apache.org:5049/axis/services/echo";; 10 11 Service service = new Service(); 12 Call call = (Call) service.createCall(); 13 14 call.setTargetEndpointAddress( new java.net.URL(endpoint) ); 15 call.setOperationName(new QName("http://soapinterop.org/";, echoString")); 16 17 String ret = (String) call.invoke( new Object[] { "Hello!" } ); 18 19 System.out.println("Sent 'Hello!', got '" + ret + "'"); 20 } catch (Exception e) { 21 System.err.println(e.toString()); 22 } 23 } 24 }

You can see that the service endpoint is a URL declared at lines
8-9. You simply have to build this URL using the host you have read from your configuration file.


If you are working with generated stubs, you will find that your
Service class has at least two get<PortName>() methods (more if you use a WS-Addressing aware generator).

One of these methods gets a URL instance as a parameter. This URL
must contain the endpoint URL, that is, the same URL you would use in the example above. Therefore, you can again build this URL using your configured host name.

You may allow configuring only a part of your endpoints, like in:

String hostName = myProps.getProperty("hostName"); URL url = new URL("http://"; + hostName + "/axis/services/echo");

or you may get the full endpoint URL from your configuration file,
like:

String echoEndpoint = myProps.getProperty("Endpoint.Echo"); URL url = new URL(echoEndpoint);

I personally think the second option gives you more freedom to
change your server deployment at will.

HTH, Rodrigo


Carsten Schmidt wrote:
Hi Rodrigo, these ideas are very interesting. First of all, thanks a lot for that. But for the first way of making the host address configurable, I
still
have to ask you, how to do that in detail? I don't mean how to read the address from a properties file, but how
can
I set the value? Carsten Am Montag, den 15.05.2006, 17:28 +0200 schrieb Rodrigo Ruiz:
Carsten, In fact, there are several ways to handle your situation, but I guess almost none of them is as simple as adding some lines to your
client
code. The ones I know are:
- Make the host address configurable. That is, read the host
address
from a configuration file. I know this is not what you are asking for, but it is probably the only easy workaround to your problem. In
fact,
I think it will be the only one that will work if you want to test your client application from the same host, and manually select the adapter to use.
- You may use DNS to provide a common name to your server, and
access
it through host name, instead of host address. This probably means
some
work to get your client domain name, in order to build the
complete
host name in each subnetwork, or be sure that using the host name
without
a domain name will return you the correct host address in all cases.
- In a more complicated fashion, you could decide to convert
your
service in a "standard" service, and register it into your DNS servers. DNS protocol allows to register the addresses for "standard" services, providing a simplistic discovery service, and allowing you to ask
for
a service name, instead of a host name. AFAIK, this option is not usual, but it should work. I am not sure, but you may probably need to
use
Jakarta commons-net library to perform such kind of queries to
your
DNS server.
- You can delegate the problem to a well-known UDDI server.
Anyway,
if you use TCP/IP, this will just move your problem from one host
to
another, as this UDDI server/s will probably also have different addresses in each sub-network. - You might use some UDP based discovery service. The idea in this case would be to send a broadcast message, and receive the
appropriate
address from some arbitrary point on your network. If you
implement
such a service in your own server, you will probably be able to get the host address from the response message meta-data itself. There are
some
standard libraries for achieving this out there, or you could try
to
implement your own, as it is plenty of examples on Google ;-) Hope this helps, Rodrigo

Carsten Schmidt wrote:
Hi Alain, thanks for your answer, but it seems as if the
NetworkInterface-class
would just be able to give you information about the interfaces. For me, it is important to tell the program which Interface to
use,
because the webserver I'm working on got different IP's in
different
sub-networks. So, I am looking for a method like setHostAdress(foo). Maybe this
is
more a part of java than axis, but the Axis-Call-class seems to
handle
the whole hardware/network-stuff on it's own. I can't believe that there is no smart way to handle this. Carsten Am Montag, den 15.05.2006, 16:28 +0200 schrieb Pannetier Alain:
Hi Carsten,
Here is an example I use to know whether I'm in the office or
at
home : try { Enumeration myInterfaces = NetworkInterface.getNetworkInterfaces(); interfaceEnum: while ( myInterfaces.hasMoreElements()) { NetworkInterface netInterf = (NetworkInterface) myInterfaces.nextElement(); Enumeration addresses =
netInterf.getInetAddresses() ;
while (addresses.hasMoreElements()) { InetAddress address = (InetAddress) addresses.nextElement(); if ( address.getHostAddress().startsWith( OFFICE_PREFIX ) ) { isAtTheOffice = true ; break interfaceEnum ; } } } } catch (SocketException e) { e.printStackTrace(); } ... It shows how to loop on all your interfaces and select one
(according
to its address prefix...). That's probably close to what your're after. Alain

-----Original Message----- From: Schmidt, Carsten -81.01-
[mailto:[EMAIL PROTECTED]
Sent: 15 May 2006 16:17 To: axis-user@ws.apache.org Subject: RE: Select the output-network-interface to call an axis-webservice Hi, did really no one every had a problem like that? This problem can not be so special, can it? But maybe you know another mailinglist or a book, which might be
able
to help me? It is really important for me to find a solution for that, and meanwhile I ain't got no more idea where to look at. Regards, Carsten
Hi everybody, maybe this question has already been answered a thousend times,
but
I
haven't found anything about it. I got a server with a few different network adapters. Each of
them
with
a different IP. Now I'm searching for a way to call a
webservice
by
choosing exacly one of those adapters (which is not the
default
one).
How can I do than? java.net.NetworkInterface shows me what is available, but where
can
it
set what to use? org.apache.axis.client.Call? org.apache.axis.client.Service? Can anybody help me? Carsten

--
-------------------------------------------------------------------
GRIDSYSTEMS Rodrigo Ruiz Aguayo Parc Bit - Son Espanyol 07120 Palma de Mallorca mailto:[EMAIL PROTECTED] Baleares - España Tel:+34-971435085 Fax:
+34-971435082
http://www.gridsystems.com
-------------------------------------------------------------------

-- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.392 / Virus Database: 268.5.6/339 - Release Date: 14/05/2006

-- ------------------------------------------------------------------- GRIDSYSTEMS Rodrigo Ruiz Aguayo Parc Bit - Son Espanyol 07120 Palma de Mallorca mailto:[EMAIL PROTECTED] Baleares - España Tel:+34-971435085 Fax:+34-971435082 http://www.gridsystems.com -------------------------------------------------------------------


-- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.392 / Virus Database: 268.5.6/339 - Release Date:
14/05/2006






--
-------------------------------------------------------------------
GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
Parc Bit - Son Espanyol
07120 Palma de Mallorca        mailto:[EMAIL PROTECTED]
Baleares - España              Tel:+34-971435085 Fax:+34-971435082
http://www.gridsystems.com
-------------------------------------------------------------------


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.5.6/339 - Release Date: 14/05/2006

Reply via email to