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 Sricharan Anand <sr...@yahoo.com> on 2006/03/11 00:51:40 UTC
Setting URN in EndpointReference class
How do we set an URN as part of EndpointReference class?
Here is my problem:
I am writing a Axis2 client to consume a remote .Net based Webservice(running WSE 2.0)
The endpoint of the service is something like this(taken from a C# client code which is working)
'Me.Url = "https://myservices.test.com/wsetestharness/myapplicationapi.asmx"
Me.Destination = New Microsoft.Web.Services2.Addressing.EndpointReference(New Uri("urn:MyApplicationAPI"), New Uri("https://myservices.test.com/wsetestharness/myapplicationapi.asmx"))
The 1st URI(urn:MyApplicationAPI) in above code is the internal address of our webservice. The 2nd Uri in the above code is the external address of our WebService.
I want to construct the same EndpointReference using the Axis2 classes. I have tried doing the following:
Uri uri1 = new URI("urn:MyApplicationAPI");
Uri uri2 = new URI("https://myservices.test.com/wsetestharness/myapplicationapi.asmx");
EndpointReference epr = new EndpointReference(uri1.toString()+uri2.toString());
_messageContext.setTo(new EndpointReference(uri1.toString()));
This does not work and i get the following exception:
org.apache.axis2.AxisFault: unknown protocol: urn; nested exception is:
java.net.MalformedURLException: unknown protocol: urn; nested exception is:
org.apache.axis2.AxisFault: unknown protocol: urn; nested exception is:
java.net.MalformedURLException: unknown protocol: urn
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:245)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:449)
---------------------------------
Relax. Yahoo! Mail virus scanning helps detect nasty viruses!
---------------------------------
Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.
Re: Setting URN in EndpointReference class
Posted by Sricharan Anand <sr...@yahoo.com>.
Hi Eran,
Thanks for your reply.
To answer your question on why my EPR has 2 addresses, please see this blog(the .Net webservice I am communicating with is using a similar architecture):
http://www.dynamic-cast.com/mt-archives/000050.html
As you can infer from the above article/blog, the first URI below becomes the EndpointReference.Address, the second URI is the EndpointReference.Via.
So i couldn't figure out how to set this in the EndpointReference class since the constructor only takes 1 string arg. Is the Via some kind of Reference property?
Related to the Malformed URL exception below, you said - So if you wanna include something like"urn:MyApplicationAPI", as your endpoint then you need to register a transport which supports urn scheme
How do i do this(register transport for urn)?
Thanks for all your help.
Regds,
Sricharan
Eran Chinthaka <ch...@opensource.lk> wrote: Hi Sricharan,
Let me explain how EndpointReference class (EPR) works with Axis2.
It models the same EPR concept in WS-Addressing EndpointReference. So
you can set only one address to that. I exactly can not understand why
you need to have two addresses, for the same EPR, one for internal and
one for external.
Having set the address property of EPR, Axis2 uses that address to
select the proper transport to send the SOAP message to the endpoing.
For example;
EndpointReference toEPR = new
EndpointReference("http://my-service-endpoint.org");
options.setTo(toEPR);
internally we search for a transport which supports the scheme of the
URL. i.e. HTTP in this case. So if you wanna include something
like"urn:MyApplicationAPI", as your endpoint then you need to register a
transport which supports urn scheme. Thats why you are getting the
exception.
If you just ignore the internal address (what do u mean by internal
address), then this should work.
EndpointReference epr = new EndpointReference(""https://myservices.test.com/wsetestharness/myapplicationapi.asmx"");
_messageContext.setTo(new EndpointReference(uri1.toString()));
HTH.
Chinthaka
Sricharan Anand wrote:
>How do we set an URN as part of EndpointReference class?
>
>Here is my problem:
>I am writing a Axis2 client to consume a remote .Net based Webservice(running WSE 2.0)
>
>The endpoint of the service is something like this(taken from a C# client code which is working)
>
>'Me.Url = "https://myservices.test.com/wsetestharness/myapplicationapi.asmx"
>Me.Destination = New Microsoft.Web.Services2.Addressing.EndpointReference(New Uri("urn:MyApplicationAPI"), New Uri("https://myservices.test.com/wsetestharness/myapplicationapi.asmx"))
>
>The 1st URI(urn:MyApplicationAPI) in above code is the internal address of our webservice. The 2nd Uri in the above code is the external address of our WebService.
>
>I want to construct the same EndpointReference using the Axis2 classes. I have tried doing the following:
>Uri uri1 = new URI("urn:MyApplicationAPI");
>Uri uri2 = new URI("https://myservices.test.com/wsetestharness/myapplicationapi.asmx");
>EndpointReference epr = new EndpointReference(uri1.toString()+uri2.toString());
>_messageContext.setTo(new EndpointReference(uri1.toString()));
>This does not work and i get the following exception:
>org.apache.axis2.AxisFault: unknown protocol: urn; nested exception is:
> java.net.MalformedURLException: unknown protocol: urn; nested exception is:
> org.apache.axis2.AxisFault: unknown protocol: urn; nested exception is:
> java.net.MalformedURLException: unknown protocol: urn
> at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:245)
> at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:449)
>
>
>
>
>---------------------------------
>Relax. Yahoo! Mail virus scanning helps detect nasty viruses!
>
>---------------------------------
>Yahoo! Mail
>Bring photos to life! New PhotoMail makes sharing a breeze.
>
>
---------------------------------
Relax. Yahoo! Mail virus scanning helps detect nasty viruses!
---------------------------------
Brings words and photos together (easily) with
PhotoMail - it's free and works with Yahoo! Mail.
Re: Setting URN in EndpointReference class
Posted by Eran Chinthaka <ch...@opensource.lk>.
Hi Sricharan,
Let me explain how EndpointReference class (EPR) works with Axis2.
It models the same EPR concept in WS-Addressing EndpointReference. So
you can set only one address to that. I exactly can not understand why
you need to have two addresses, for the same EPR, one for internal and
one for external.
Having set the address property of EPR, Axis2 uses that address to
select the proper transport to send the SOAP message to the endpoing.
For example;
EndpointReference toEPR = new
EndpointReference("http://my-service-endpoint.org");
options.setTo(toEPR);
internally we search for a transport which supports the scheme of the
URL. i.e. HTTP in this case. So if you wanna include something
like"urn:MyApplicationAPI", as your endpoint then you need to register a
transport which supports urn scheme. Thats why you are getting the
exception.
If you just ignore the internal address (what do u mean by internal
address), then this should work.
EndpointReference epr = new EndpointReference(""https://myservices.test.com/wsetestharness/myapplicationapi.asmx"");
_messageContext.setTo(new EndpointReference(uri1.toString()));
HTH.
Chinthaka
Sricharan Anand wrote:
>How do we set an URN as part of EndpointReference class?
>
>Here is my problem:
>I am writing a Axis2 client to consume a remote .Net based Webservice(running WSE 2.0)
>
>The endpoint of the service is something like this(taken from a C# client code which is working)
>
>'Me.Url = "https://myservices.test.com/wsetestharness/myapplicationapi.asmx"
>Me.Destination = New Microsoft.Web.Services2.Addressing.EndpointReference(New Uri("urn:MyApplicationAPI"), New Uri("https://myservices.test.com/wsetestharness/myapplicationapi.asmx"))
>
>The 1st URI(urn:MyApplicationAPI) in above code is the internal address of our webservice. The 2nd Uri in the above code is the external address of our WebService.
>
>I want to construct the same EndpointReference using the Axis2 classes. I have tried doing the following:
>Uri uri1 = new URI("urn:MyApplicationAPI");
>Uri uri2 = new URI("https://myservices.test.com/wsetestharness/myapplicationapi.asmx");
>EndpointReference epr = new EndpointReference(uri1.toString()+uri2.toString());
>_messageContext.setTo(new EndpointReference(uri1.toString()));
>This does not work and i get the following exception:
>org.apache.axis2.AxisFault: unknown protocol: urn; nested exception is:
> java.net.MalformedURLException: unknown protocol: urn; nested exception is:
> org.apache.axis2.AxisFault: unknown protocol: urn; nested exception is:
> java.net.MalformedURLException: unknown protocol: urn
> at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:245)
> at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:449)
>
>
>
>
>---------------------------------
>Relax. Yahoo! Mail virus scanning helps detect nasty viruses!
>
>---------------------------------
>Yahoo! Mail
>Bring photos to life! New PhotoMail makes sharing a breeze.
>
>