Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Axis2 web service How to Make Web Service Address Configurable

637 views
Skip to first unread message

zigz...@yahoo.com

unread,
Jul 31, 2013, 12:30:44 AM7/31/13
to
Subject: Axis2 web service How to Make Web Service Address Configurable

I am generating client and web service code from a wsdl file. Now my wsdl file has following for web service end point address:
<wsdl:service name="SG910_BtB_IN0138_NonConformances_ETS_Source_v1.webService.receiveNonConformanceWS">
- <wsdl:port name="SG910_BtB_IN0138_NonConformances_ETS_Source_v1_webService_receiveNonConformanceWS_Port" binding="tns:SG910_BtB_IN0138_NonConformances_ETS_Source_v1_webService_receiveNonConformanceWS_Binder">
<soap:address location="http://itsusmpl00082.jnj.com:7996/ws/SG910_BtB_IN0138_NonConformances_ETS_Source_v1.webService.receiveNonConformanceWS/SG910_BtB_IN0138_NonConformances_ETS_Source_v1_webService_receiveNonConformanceWS_Port" />
</wsdl:port>
</wsdl:service>


Now location is here is hardcoded to refer to some address. Now I am using wsdl2java to generate code. But code has address hardcoded. Since this address can change from dev to qa to prod. How can I make generated code independent of address; i.e., generated code will work across all environments.

I am new to axis2 and this code generation, so appreciate any guidance,


Sebastian

unread,
Jul 31, 2013, 1:26:55 AM7/31/13
to
if the endpoints are different, I guess there would be multiple wsdl's,
each appropriate to the environment. So you could
a) generate the code for each environment separately
b) use Ant or Maven to deploy the code appropriate for each environment.

Alternatively, perhaps you could do the code generation in each of the
environments (perhaps even at runtime) and load the artifacts dynamically.

-- Sebastian

zigz...@yahoo.com

unread,
Jul 31, 2013, 12:28:10 PM7/31/13
to
On Wednesday, July 31, 2013 1:26:55 AM UTC-4, Sebastian wrote:
> Am 31.07.2013 06:30, schrieb zigz...@yahoo.com: > Subject: Axis2 web service How to Make Web Service Address Configurable > > I am generating client and web service code from a wsdl file. Now my wsdl file has following for web service end point address: > <wsdl:service name="SG910_BtB_IN0138_NonConformances_ETS_Source_v1.webService.receiveNonConformanceWS"> > -<wsdl:port name="SG910_BtB_IN0138_NonConformances_ETS_Source_v1_webService_receiveNonConformanceWS_Port" binding="tns:SG910_BtB_IN0138_NonConformances_ETS_Source_v1_webService_receiveNonConformanceWS_Binder"> > <soap:address location="http://itsusmpl00082.jnj.com:7996/ws/SG910_BtB_IN0138_NonConformances_ETS_Source_v1.webService.receiveNonConformanceWS/SG910_BtB_IN0138_NonConformances_ETS_Source_v1_webService_receiveNonConformanceWS_Port" /> > </wsdl:port> > </wsdl:service> > > > Now location is here is hardcoded to refer to some address. Now I am using wsdl2java to generate code. But code has address hardcoded. Since this address can change from dev to qa to prod. How can I make generated code independent of address; i.e., generated code will work across all environments. > > I am new to axis2 and this code generation, so appreciate any guidance, > > if the endpoints are different, I guess there would be multiple wsdl's, each appropriate to the environment. So you could a) generate the code for each environment separately b) use Ant or Maven to deploy the code appropriate for each environment. Alternatively, perhaps you could do the code generation in each of the environments (perhaps even at runtime) and load the artifacts dynamically. -- Sebastian

Thanks, but there has to be a better way, so code is generated only once and then modified so it becomes independentof the environment and web service URL etc are configurable in some file. Google erach shows some information which is confusing.

Arved Sandstrom

unread,
Jul 31, 2013, 5:04:55 PM7/31/13
to
It's been quite a while since I used Axis, I've preferred CXF for years,
but it doesn't much matter since it's all about conforming to JAX-WS.

When I use CXF and generate client code, for example, I do get that
annoying hardcoded @WebServiceClient annotation. Point being, that's
information for the default javax.xml.ws.Service constructor...but there
is another constructor where you can provide a different WSDL URL.

AHS

--
When a true genius appears, you can know him by this sign:
that all the dunces are in a confederacy against him.
-- Jonathan Swift

Lew

unread,
Jul 31, 2013, 5:14:52 PM7/31/13
to
I always used to just WSDL the URL with a "localhost/..." and just had Axis call the actual
URL at run time.

--
Lew

zigz...@yahoo.com

unread,
Jul 31, 2013, 6:07:53 PM7/31/13
to
Thanks, I will do just that.

Lew

unread,
Jul 31, 2013, 8:47:13 PM7/31/13
to
zigz...@yahoo.com wrote:
> Lew wrote:
>> I always used to just WSDL the URL with a "localhost/..." and just had Axis call the actual
>> URL at run time.
>
> Thanks, I will do just that.

One caveat - this was an old version of Axis a few years ago. I can't guarantee the behavior is the
same now.

In those days, at least, the system somehow figured out the right URL at run time.

--
Lew

Arved Sandstrom

unread,
Jul 31, 2013, 9:04:06 PM7/31/13
to
I think we're all talking the same approach here. For WSDL-first the
generated @WebServiceClient annotation is more documentation and tools
support than anything else; the code that calls the client stub can
choose what actual endpoint URL and QName to supply. The WSDL URL can be
externally configured; the annotation can be reflected to manufacture
the QName...after all, if this latter changes then the WSDL itself
changed and you have generated new client code.

Arne Vajhøj

unread,
Jul 31, 2013, 11:26:10 PM7/31/13
to
On 7/31/2013 12:30 AM, zigz...@yahoo.com wrote:
> Subject: Axis2 web service How to Make Web Service Address Configurable

> Now location is here is hardcoded to refer to some address. Now I am
> using wsdl2java to generate code. But code has address hardcoded. Since
> this address can change from dev to qa to prod. How can I make generated
> code independent of address; i.e., generated code will work across all
> environments.
>
> I am new to axis2 and this code generation, so appreciate any guidance,

If you use stub generated by Java SE wsimport, then you can specify the
URL of the WSDL in the service constructor.

If you make a manual call using standard JAX-WS, then you specify
the URL of the WSDL in the service create method.

If you use stub generated by Axis2 WSDL2Java or codegen ant task, then
you can specify the URL of the service itself in the service
constructor.

Arne

0 new messages