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 Jing Tao <ta...@nceas.ucsb.edu> on 2006/11/02 20:33:22 UTC

Relative URL

Hi, devs:

I have a question about relative URL in axis.

I have a wsdl file and it has element named namespace and its type is 
anyURI (http://www.w3.org/2001/XMLSchema). After running wsdl2java, this 
element is declared as org.apache.axis.types.URI automatically. Here is 
segment of code in auto generated stub code:

public QueryTypeNamespace(java.lang.String _value) {
         try {
             this._value = new org.apache.axis.types.URI(_value);
         }
         catch (org.apache.axis.types.URI.MalformedURIException mue) {
             throw new java.lang.RuntimeException(mue.toString());
        }
     }

If in this element, the namespace has a schema(e.g. http://mynamespace), 
it works perfect. However, if the namespace is relative URI (without 
schema, e.g.mynamespace), the above code will throw an exception.

I took a look at API of org.apache.axis.types.URI. It has another 
constructor URI(String uri, boolean allowNonAbosluteURI). If I manully 
use this constructor, the code will work with relative URI.

The above code was generated by ant tast - axis-wsdl2java. And here is the 
piece of wsdl file:

<xs:element name="namespace">
                 <xs:complexType>
                     <xs:simpleContent>
                         <xs:extension base="xs:anyURI">
                             <xs:attribute name="prefix"
                                 type="xs:string" use="optional"/>
                         </xs:extension>
                     </xs:simpleContent>
                 </xs:complexType>
</xs:element>

My question is without changing wsdl file, how can I make the auto 
generated code working with relative URI?

Thanks a lot!

Jing


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Relative URL

Posted by Martin Gainty <mg...@hotmail.com>.
Good Evening Jing-
implement these few mods  in org.apache.axis2.wsdl.WSDL2Code.java/re-compile and re-gen your code against valid wsdl (in this case PingService)
java org.apache.axis2.wsdl.WSDL2Java -uri file:///usr/local/Axis/Axis-2_1/src/modules/codegen/src/PingService.wsdl
the generator will regen both
./src/org/xmlsoap/ping/PingServiceCallbackHandler.java 
./src/org/xmlsoap/ping/PingServiceStub.java 

    public static void main(String[] args) throws Exception
    {
        CommandLineOptionParser commandLineOptionParser=null;
        try
        {
  if(new String(args[0]).indexOf("http") == -1)
  {
         commandLineOptionParser = new CommandLineOptionParser(args);
     }
     else
     {
   String new_args[]=null;
   new_args[0] = "http";
   for (int i=1; i<99; i++)
   {
    try
    {
     if(args[i]==null) break;
     new_args[i] = args[i-1];
       }
       catch(ArrayIndexOutOfBoundsException aoe)
       {
     break;
       }
       catch(NullPointerException npe)
       {
     break;
       }
      }
   commandLineOptionParser = new CommandLineOptionParser(new_args);
     }
     } //end try
     catch(ArrayIndexOutOfBoundsException aoe2)
     {
   System.out.println("WSDL2Code WSDLFile");
   System.exit(0);
  }
        validateCommandLineOptions(commandLineOptionParser);
        new CodeGenerationEngine(commandLineOptionParser).generate();

    }

HTH,
Martin --
This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
contents
----- Original Message ----- 
From: "Jing Tao" <ta...@nceas.ucsb.edu>
To: <ax...@ws.apache.org>; "Martin Gainty" <mg...@hotmail.com>
Sent: Thursday, November 02, 2006 6:09 PM
Subject: Re: Relative URL


> Thank you for response, Martin!
> 
> In my case, namespace is part of query. According to the auto-generated 
> class, my query only can search a documents which has a well-formed 
> namespace. However, I have some documents don't have well-formed 
> namespace. So I want the code can handle the relative url too.
> 
> for example, if I want search document which namespace's value is 
> "http://foo". I will have "<namespace>http://foo</namespace>". And the 
> code will work fine. But if I want search documents which have namespace 
> "foo". Then I will set "<namespace>foo</namespace>". In this case, the 
> code doesn't work.
> 
> I want to know how to make auto-generate can accept those relative URI.
> 
> Thanks,
> 
> Jing
> 
> 
> Jing Tao
> National Center for Ecological
> Analysis and Synthesis (NCEAS)
> 735 State St. Suite 204
> Santa Barbara, CA 93101
> 
> On Thu, 2 Nov 2006, Martin Gainty wrote:
> 
>> Date: Thu, 2 Nov 2006 15:09:17 -0500
>> From: Martin Gainty <mg...@hotmail.com>
>> Reply-To: axis-user@ws.apache.org, Martin Gainty <mg...@hotmail.com>
>> To: axis-user@ws.apache.org
>> Subject: Re: Relative URL
>> 
>> you can use a 2 stage constructor(URI base,String relativeURISpec) where the first parameter would contain the critical attributes of
>> base path
>> relative path appended to base
>> the initial base path requires the following data elements to properly construct a URI object
>>        userinfo
>>        host
>>        port
>>        regAuthority
>>        base_path
>> otherwise the final URI class has no ability to construct the full path from partial URI path
>>
>> M-
>> This e-mail communication and any attachments may contain confidential and privileged information for the use of the
>> designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
>> this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its
>> contents
>> ----- Original Message -----
>> From: "Jing Tao" <ta...@nceas.ucsb.edu>
>> To: <ax...@ws.apache.org>
>> Sent: Thursday, November 02, 2006 2:33 PM
>> Subject: Relative URL
>>
>>
>>> Hi, devs:
>>>
>>> I have a question about relative URL in axis.
>>>
>>> I have a wsdl file and it has element named namespace and its type is
>>> anyURI (http://www.w3.org/2001/XMLSchema). After running wsdl2java, this
>>> element is declared as org.apache.axis.types.URI automatically. Here is
>>> segment of code in auto generated stub code:
>>>
>>> public QueryTypeNamespace(java.lang.String _value) {
>>>         try {
>>>             this._value = new org.apache.axis.types.URI(_value);
>>>         }
>>>         catch (org.apache.axis.types.URI.MalformedURIException mue) {
>>>             throw new java.lang.RuntimeException(mue.toString());
>>>        }
>>>     }
>>>
>>> If in this element, the namespace has a schema(e.g. http://mynamespace),
>>> it works perfect. However, if the namespace is relative URI (without
>>> schema, e.g.mynamespace), the above code will throw an exception.
>>>
>>> I took a look at API of org.apache.axis.types.URI. It has another
>>> constructor URI(String uri, boolean allowNonAbosluteURI). If I manully
>>> use this constructor, the code will work with relative URI.
>>>
>>> The above code was generated by ant tast - axis-wsdl2java. And here is the
>>> piece of wsdl file:
>>>
>>> <xs:element name="namespace">
>>>                 <xs:complexType>
>>>                     <xs:simpleContent>
>>>                         <xs:extension base="xs:anyURI">
>>>                             <xs:attribute name="prefix"
>>>                                 type="xs:string" use="optional"/>
>>>                         </xs:extension>
>>>                     </xs:simpleContent>
>>>                 </xs:complexType>
>>> </xs:element>
>>>
>>> My question is without changing wsdl file, how can I make the auto
>>> generated code working with relative URI?
>>>
>>> Thanks a lot!
>>>
>>> Jing
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
>

Re: Relative URL

Posted by Jing Tao <ta...@nceas.ucsb.edu>.
Thank you for response, Martin!

In my case, namespace is part of query. According to the auto-generated 
class, my query only can search a documents which has a well-formed 
namespace. However, I have some documents don't have well-formed 
namespace. So I want the code can handle the relative url too.

for example, if I want search document which namespace's value is 
"http://foo". I will have "<namespace>http://foo</namespace>". And the 
code will work fine. But if I want search documents which have namespace 
"foo". Then I will set "<namespace>foo</namespace>". In this case, the 
code doesn't work.

I want to know how to make auto-generate can accept those relative URI.

Thanks,

Jing


Jing Tao
National Center for Ecological
Analysis and Synthesis (NCEAS)
735 State St. Suite 204
Santa Barbara, CA 93101

On Thu, 2 Nov 2006, Martin Gainty wrote:

> Date: Thu, 2 Nov 2006 15:09:17 -0500
> From: Martin Gainty <mg...@hotmail.com>
> Reply-To: axis-user@ws.apache.org, Martin Gainty <mg...@hotmail.com>
> To: axis-user@ws.apache.org
> Subject: Re: Relative URL
> 
> you can use a 2 stage constructor(URI base,String relativeURISpec) where the first parameter would contain the critical attributes of
> base path
> relative path appended to base
> the initial base path requires the following data elements to properly construct a URI object
>        userinfo
>        host
>        port
>        regAuthority
>        base_path
> otherwise the final URI class has no ability to construct the full path from partial URI path
>
> M-
> This e-mail communication and any attachments may contain confidential and privileged information for the use of the
> designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
> this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its
> contents
> ----- Original Message -----
> From: "Jing Tao" <ta...@nceas.ucsb.edu>
> To: <ax...@ws.apache.org>
> Sent: Thursday, November 02, 2006 2:33 PM
> Subject: Relative URL
>
>
>> Hi, devs:
>>
>> I have a question about relative URL in axis.
>>
>> I have a wsdl file and it has element named namespace and its type is
>> anyURI (http://www.w3.org/2001/XMLSchema). After running wsdl2java, this
>> element is declared as org.apache.axis.types.URI automatically. Here is
>> segment of code in auto generated stub code:
>>
>> public QueryTypeNamespace(java.lang.String _value) {
>>         try {
>>             this._value = new org.apache.axis.types.URI(_value);
>>         }
>>         catch (org.apache.axis.types.URI.MalformedURIException mue) {
>>             throw new java.lang.RuntimeException(mue.toString());
>>        }
>>     }
>>
>> If in this element, the namespace has a schema(e.g. http://mynamespace),
>> it works perfect. However, if the namespace is relative URI (without
>> schema, e.g.mynamespace), the above code will throw an exception.
>>
>> I took a look at API of org.apache.axis.types.URI. It has another
>> constructor URI(String uri, boolean allowNonAbosluteURI). If I manully
>> use this constructor, the code will work with relative URI.
>>
>> The above code was generated by ant tast - axis-wsdl2java. And here is the
>> piece of wsdl file:
>>
>> <xs:element name="namespace">
>>                 <xs:complexType>
>>                     <xs:simpleContent>
>>                         <xs:extension base="xs:anyURI">
>>                             <xs:attribute name="prefix"
>>                                 type="xs:string" use="optional"/>
>>                         </xs:extension>
>>                     </xs:simpleContent>
>>                 </xs:complexType>
>> </xs:element>
>>
>> My question is without changing wsdl file, how can I make the auto
>> generated code working with relative URI?
>>
>> Thanks a lot!
>>
>> Jing
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Relative URL

Posted by Martin Gainty <mg...@hotmail.com>.
you can use a 2 stage constructor(URI base,String relativeURISpec) where the first parameter would contain the critical attributes of
base path
relative path appended to base
the initial base path requires the following data elements to properly construct a URI object
        userinfo
        host 
        port 
        regAuthority 
        base_path 
otherwise the final URI class has no ability to construct the full path from partial URI path

M-
This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
contents
----- Original Message ----- 
From: "Jing Tao" <ta...@nceas.ucsb.edu>
To: <ax...@ws.apache.org>
Sent: Thursday, November 02, 2006 2:33 PM
Subject: Relative URL


> Hi, devs:
> 
> I have a question about relative URL in axis.
> 
> I have a wsdl file and it has element named namespace and its type is 
> anyURI (http://www.w3.org/2001/XMLSchema). After running wsdl2java, this 
> element is declared as org.apache.axis.types.URI automatically. Here is 
> segment of code in auto generated stub code:
> 
> public QueryTypeNamespace(java.lang.String _value) {
>         try {
>             this._value = new org.apache.axis.types.URI(_value);
>         }
>         catch (org.apache.axis.types.URI.MalformedURIException mue) {
>             throw new java.lang.RuntimeException(mue.toString());
>        }
>     }
> 
> If in this element, the namespace has a schema(e.g. http://mynamespace), 
> it works perfect. However, if the namespace is relative URI (without 
> schema, e.g.mynamespace), the above code will throw an exception.
> 
> I took a look at API of org.apache.axis.types.URI. It has another 
> constructor URI(String uri, boolean allowNonAbosluteURI). If I manully 
> use this constructor, the code will work with relative URI.
> 
> The above code was generated by ant tast - axis-wsdl2java. And here is the 
> piece of wsdl file:
> 
> <xs:element name="namespace">
>                 <xs:complexType>
>                     <xs:simpleContent>
>                         <xs:extension base="xs:anyURI">
>                             <xs:attribute name="prefix"
>                                 type="xs:string" use="optional"/>
>                         </xs:extension>
>                     </xs:simpleContent>
>                 </xs:complexType>
> </xs:element>
> 
> My question is without changing wsdl file, how can I make the auto 
> generated code working with relative URI?
> 
> Thanks a lot!
> 
> Jing
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
>