You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kalle Korhonen <ka...@gmail.com> on 2008/03/23 00:28:32 UTC

Override schemalocation when creating a client

Hello cxfers,

I'm trying to consume some web service with jaxws/cxf. I use Service.create(new
URL("http://some.server/service?wsdl"), SERVICE_NAME). The service's wsdl
imports xsd with a relative schemaLocation (e.g xsd:import
namespace="servicens" schemaLocation="servicens.xsd") , but the .xsds are
not available through the server (from http://some.server/servicens.xsd), so
constructing the service (client) fails with FileNotFoundException. I have
the xsds but I don't know how to tell cxf's servicefactory where the xsds
are located. I've seen quite a few other threads on the list related to
resolving references to xsds but the service is not mine so I cannot change
the references or make the xsds available on the server. If I point to a
local wsdl, the service factory doesn't even try to resolve the schemas;
probably because it's setting the validation off, but I don't know how to
control that. Anybody able to help me?

Kalle

Re: Override schemalocation when creating a client

Posted by Benson Margulies <bi...@gmail.com>.
The catalog manager might help, but, really, Glen's suggestion will lead to
much faster performance.

On Sun, Mar 23, 2008 at 1:47 AM, Glen Mazza <gl...@verizon.net> wrote:

> I'm not sure, but I think you're trying to create a dynamic client which
> is unfortunately not working for you.  Hopefully someone else can answer
> your specific question on this, but in the meantime, you might wish to
> try the more traditional route of getting the WSDL and XSD's on your
> machine locally, running wsdl2java and then coding your SOAP client
> using the wsdl2java artifacts generated, similar to here[1].  Once done,
> any missing XSD's from the server should no longer be a concern for you.
>
> HTH,
> Glen
>
> [1] http://www.jroller.com/gmazza/date/20070929
>
>
> Am Samstag, den 22.03.2008, 16:28 -0700 schrieb Kalle Korhonen:
> > Hello cxfers,
> >
> > I'm trying to consume some web service with jaxws/cxf. I use
> Service.create(new
> > URL("http://some.server/service?wsdl"), SERVICE_NAME). The service's
> wsdl
> > imports xsd with a relative schemaLocation (e.g xsd:import
> > namespace="servicens" schemaLocation="servicens.xsd") , but the .xsds
> are
> > not available through the server (from http://some.server/servicens.xsd),
> so
> > constructing the service (client) fails with FileNotFoundException. I
> have
> > the xsds but I don't know how to tell cxf's servicefactory where the
> xsds
> > are located. I've seen quite a few other threads on the list related to
> > resolving references to xsds but the service is not mine so I cannot
> change
> > the references or make the xsds available on the server. If I point to a
> > local wsdl, the service factory doesn't even try to resolve the schemas;
> > probably because it's setting the validation off, but I don't know how
> to
> > control that. Anybody able to help me?
> >
> > Kalle
>
>

Re: Override schemalocation when creating a client

Posted by Kalle Korhonen <ka...@gmail.com>.
On Mon, Mar 24, 2008 at 12:57 AM, Jervis Liu <je...@gmail.com> wrote:

> On Mon, Mar 24, 2008 at 12:54 PM, Kalle Korhonen <
> kalle.o.korhonen@gmail.com>
> wrote:
> > On Sun, Mar 23, 2008 at 4:50 PM, Glen Mazza <gl...@verizon.net>
> > wrote:
> > > I have not coded that way before, nor needed to.  Can you not just set
> > > the ENDPOINT_ADDRESS_PROPERTY as done here[1], step #7?
> > That would work, but I don't think it's any easier or more correct than:
> >        QName newServicePort = new QName("urn:some:service", "newport");
> >        service.addPort(newServicePort,
> > javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING,"
> http://newserver/service
> > ");
> >        servicePort = service.getPort(newServicePort,
> > ServiceInterface.class
> > );
> You only use addPort in the case of using Dispatch on your client side.
> This
> is because ports created in this way contain no WSDL port type
> information.
> In the code snippet you gave above, for any port you created by using
> service.addPort(), it wont be returned by service.getPort(...). In CXF,
> service.getPort(..) only returns these ports that can be initialized
> according to the port type information in WSDL.
>

Ok, ENDPOINT_ADDRESS_PROPERTY it is then. Related to your earlier response;
I don't know the service location at compile time and modifying a local wsdl
at run-time just for the address would be a rather cumbersome approach.

Kalle


> Otherwise, the JAX WS 2.1 specification, in Section 5.2.5.4
> > ("Application-Specified Service") seems to define the manner of making
> > web services calls as you do below.  For XSD resolution, it also
> > requires using either the "catalog facility" defined in Section 4.4 or
> > "metadata documents".  I would guess you would want to create the former
> > for your SOAP client calls to work.
>
>
> Thanks for pointing out section 4.4. I didn't really feel like configuring
> the default XML catalog for the xml parser and didn't see any way of
> providing custom entity resolvers. Hadn't noticed META-INF/jax-
> ws-catalog.xml, that looks exactly like what I was looking for.
>
> Kalle
>
>
>
> > Am Sonntag, den 23.03.2008, 14:39 -0700 schrieb Kalle Korhonen:
> > > On Sat, Mar 22, 2008 at 10:47 PM, Glen Mazza <gl...@verizon.net>
> > wrote:
> > >
> > > > I'm not sure, but I think you're trying to create a dynamic client
> > which
> > > > is unfortunately not working for you.  Hopefully someone else can
> > answer
> > > > your specific question on this, but in the meantime, you might wish
> to
> > > > try the more traditional route of getting the WSDL and XSD's on your
> > > > machine locally, running wsdl2java and then coding your SOAP client
> > > > using the wsdl2java artifacts generated, similar to here[1].  Once
> > done,
> > > > any missing XSD's from the server should no longer be a concern for
> > you.
> > > >
> > >
> > > But it is a concern. I have the generated service stubs, but if I
> create
> > the
> > > service by specifying the the server url (Service.create(new
> > > URL("http://<http://some.server/service?wsdl>..."),
> > > it'll try to fetch the xsds and fails because of that. The same
> doesn't
> > > happen if I point to a wsdl from classpath. I need to be able to
> specify
> > the
> > > service location in code, and obviously I can add a new service port
> > > dynamically (Service.addPort) to make it work. But that's not the
> point;
> > I
> > > believe the spec says the schemaLocation is only a hint and
> furthermore,
> > I
> > > should be able to use the service without forced validation, don't you
> > > think?
> > >
> > > Kalle
> > >
> > >
> > > Am Samstag, den 22.03.2008, 16:28 -0700 schrieb Kalle Korhonen:
> > > > > Hello cxfers,
> > > > >
> > > > > I'm trying to consume some web service with jaxws/cxf. I use
> > > > Service.create(new
> > > > > URL("http://some.server/service?wsdl"), SERVICE_NAME). The
> service's
> > > > wsdl
> > > > > imports xsd with a relative schemaLocation (e.g xsd:import
> > > > > namespace="servicens" schemaLocation="servicens.xsd") , but the
> > .xsds
> > > > are
> > > > > not available through the server (from
> > http://some.server/servicens.xsd),
> > > > so
> > > > > constructing the service (client) fails with
> FileNotFoundException.
> > I
> > > > have
> > > > > the xsds but I don't know how to tell cxf's servicefactory where
> the
> > > > xsds
> > > > > are located. I've seen quite a few other threads on the list
> related
> > to
> > > > > resolving references to xsds but the service is not mine so I
> cannot
> > > > change
> > > > > the references or make the xsds available on the server. If I
> point
> > to a
> > > > > local wsdl, the service factory doesn't even try to resolve the
> > schemas;
> > > > > probably because it's setting the validation off, but I don't know
> > how
> > > > to
> > > > > control that. Anybody able to help me?
> > > > >
> > > > > Kalle
> > > >
> > > >
> >
> >
>

RE: How I can set 'Home' or 'Root' or 'Docbase' directory?

Posted by "Alpin, Luba" <Lu...@lsi.com>.
Hi Glen Mazza!
Thank you for replay!
I want show you snip from my server code for clarify my questions. I
don't use explicitly wsdl or xml configuration or servlet container I
run class that execute binary of following code for Services Test(1-68)

        HashMap<String, Object> props = new HashMap<String, Object>();
        props.put(AegisDatabinding.WRITE_XSI_TYPE_KEY, true);
        ArrayList<String> l = new ArrayList<String>();
        l.add(CustomType1.class.getName());
        l.add(CustomType2.class.getName());
        l.add(CustomType3.class.getName());
        props.put(AegisDatabinding.OVERRIDE_TYPES_KEY, l);

//publishing first service Test1
        ServerFactoryBean svrFactory = new ServerFactoryBean();
        Test1 impl = new Test1Impl();
        svrFactory.setServiceClass(Test1.class);
        svrFactory.setAddress(ADDRESS + "Test1");
        svrFactory.setProperties(props);
        svrFactory.setServiceBean(impl);
        svrFactory.getServiceFactory().setDataBinding(new
AegisDatabinding());
        svrFactory.getServiceFactory().setProperties(props);
        svrFactory.create();

 //publishing second service Test2
        ServerFactoryBean svrFactory1 = new ServerFactoryBean();
        Test2 impl = new Test2Impl();
        svrFactory1.setServiceClass(Test2.class);
        svrFactory1.setAddress(ADDRESS + "Test2");
        svrFactory1.setProperties(props);
        svrFactory1.setServiceBean(impl);
        svrFactory1.getServiceFactory().setDataBinding(new
AegisDatabinding());
        svrFactory1.getServiceFactory().setProperties(props);
        svrFactory1.create();

the same for (Test2...68)

-----Original Message-----
From: Glen Mazza [mailto:glen.mazza@gmail.com] 
Sent: Monday, March 24, 2008 5:47 PM
To: cxf-user@incubator.apache.org
Subject: Re: How I can set 'Home' or 'Root' or 'Docbase' directory?


1.  That seems strange.  Unless I'm not understanding you correctly, I
would
think you just want to create one WSDL with 68 services
(wsdl:operations),
and then proceed as follows: http://www.jroller.com/gmazza/date/20071019


2.  It depends on your servlet container, not the web service stack.  A
simple way, for starters at least, is to rely on your classpath--see my
last
comment at the very bottom of:
http://www.jroller.com/gmazza/date/20071102.

3.
http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-sup
port.html. 
Read carefully.  The upcoming 2.0.5 (in a week or two) will make things
a
little bit simpler: http://www.jroller.com/gmazza/date/20080322

Glen


Alpin, Luba wrote:
> 
> Hi CXF-User-List,
> I need your help with my three questions, please HELP!
> 
> 1. I want to publish 68 services using ServerFactoryBean I create 68
> instances ServerFactoryBean - one for each service, is it correct
usage
> of ServerFactoryBean? After 34 services I get OutOfMemory exception
and
> this enforces me increase memory to -Xmx128m , while XFire enable do
it
> with a default 64.
> 
> 2. I want create webserver root directory to store files for
downloading
> client.
> With XFire this is root directory located in root of Jetty server. How
I
> do it with CXF? Do I need create Jetty server and start it additional
to
> calling create method for each ServerFactoryBean instance?
> 
> 3. Https? Please link to example.
> 
> Thanks for help.
> Luba Alpin.
> 
> 

-- 
View this message in context:
http://www.nabble.com/Override-schemalocation-when-creating-a-client-tp1
6228867p16254688.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How I can set 'Home' or 'Root' or 'Docbase' directory?

Posted by Glen Mazza <gl...@gmail.com>.
1.  That seems strange.  Unless I'm not understanding you correctly, I would
think you just want to create one WSDL with 68 services (wsdl:operations),
and then proceed as follows: http://www.jroller.com/gmazza/date/20071019  

2.  It depends on your servlet container, not the web service stack.  A
simple way, for starters at least, is to rely on your classpath--see my last
comment at the very bottom of: http://www.jroller.com/gmazza/date/20071102.

3.
http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-support.html. 
Read carefully.  The upcoming 2.0.5 (in a week or two) will make things a
little bit simpler: http://www.jroller.com/gmazza/date/20080322

Glen


Alpin, Luba wrote:
> 
> Hi CXF-User-List,
> I need your help with my three questions, please HELP!
> 
> 1. I want to publish 68 services using ServerFactoryBean I create 68
> instances ServerFactoryBean - one for each service, is it correct usage
> of ServerFactoryBean? After 34 services I get OutOfMemory exception and
> this enforces me increase memory to -Xmx128m , while XFire enable do it
> with a default 64.
> 
> 2. I want create webserver root directory to store files for downloading
> client.
> With XFire this is root directory located in root of Jetty server. How I
> do it with CXF? Do I need create Jetty server and start it additional to
> calling create method for each ServerFactoryBean instance?
> 
> 3. Https? Please link to example.
> 
> Thanks for help.
> Luba Alpin.
> 
> 

-- 
View this message in context: http://www.nabble.com/Override-schemalocation-when-creating-a-client-tp16228867p16254688.html
Sent from the cxf-user mailing list archive at Nabble.com.


How I can set 'Home' or 'Root' or 'Docbase' directory?

Posted by "Alpin, Luba" <Lu...@lsi.com>.
Hi CXF-User-List,
I need your help with my three questions, please HELP!

1. I want to publish 68 services using ServerFactoryBean I create 68
instances ServerFactoryBean - one for each service, is it correct usage
of ServerFactoryBean? After 34 services I get OutOfMemory exception and
this enforces me increase memory to -Xmx128m , while XFire enable do it
with a default 64.

2. I want create webserver root directory to store files for downloading
client.
With XFire this is root directory located in root of Jetty server. How I
do it with CXF? Do I need create Jetty server and start it additional to
calling create method for each ServerFactoryBean instance?

3. Https? Please link to example.

Thanks for help.
Luba Alpin.

Re: Override schemalocation when creating a client

Posted by Jervis Liu <je...@gmail.com>.
On Mon, Mar 24, 2008 at 12:54 PM, Kalle Korhonen <ka...@gmail.com>
wrote:

> On Sun, Mar 23, 2008 at 4:50 PM, Glen Mazza <gl...@verizon.net>
> wrote:
>
> > I have not coded that way before, nor needed to.  Can you not just set
> > the ENDPOINT_ADDRESS_PROPERTY as done here[1], step #7?
>
>
> That would work, but I don't think it's any easier or more correct than:
>        QName newServicePort = new QName("urn:some:service", "newport");
>        service.addPort(newServicePort,
> javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING,"http://newserver/service
> ");
>        servicePort = service.getPort(newServicePort,
> ServiceInterface.class
> );


You only use addPort in the case of using Dispatch on your client side. This
is because ports created in this way contain no WSDL port type information.
In the code snippet you gave above, for any port you created by using
service.addPort(), it wont be returned by service.getPort(...). In CXF,
service.getPort(..) only returns these ports that can be initialized
according to the port type information in WSDL.


> Otherwise, the JAX WS 2.1 specification, in Section 5.2.5.4
> > ("Application-Specified Service") seems to define the manner of making
> > web services calls as you do below.  For XSD resolution, it also
> > requires using either the "catalog facility" defined in Section 4.4 or
> > "metadata documents".  I would guess you would want to create the former
> > for your SOAP client calls to work.
>
>
> Thanks for pointing out section 4.4. I didn't really feel like configuring
> the default XML catalog for the xml parser and didn't see any way of
> providing custom entity resolvers. Hadn't noticed META-INF/jax-
> ws-catalog.xml, that looks exactly like what I was looking for.
>
> Kalle
>
>
>
> > Am Sonntag, den 23.03.2008, 14:39 -0700 schrieb Kalle Korhonen:
> > > On Sat, Mar 22, 2008 at 10:47 PM, Glen Mazza <gl...@verizon.net>
> > wrote:
> > >
> > > > I'm not sure, but I think you're trying to create a dynamic client
> > which
> > > > is unfortunately not working for you.  Hopefully someone else can
> > answer
> > > > your specific question on this, but in the meantime, you might wish
> to
> > > > try the more traditional route of getting the WSDL and XSD's on your
> > > > machine locally, running wsdl2java and then coding your SOAP client
> > > > using the wsdl2java artifacts generated, similar to here[1].  Once
> > done,
> > > > any missing XSD's from the server should no longer be a concern for
> > you.
> > > >
> > >
> > > But it is a concern. I have the generated service stubs, but if I
> create
> > the
> > > service by specifying the the server url (Service.create(new
> > > URL("http://<http://some.server/service?wsdl>..."),
> > > it'll try to fetch the xsds and fails because of that. The same
> doesn't
> > > happen if I point to a wsdl from classpath. I need to be able to
> specify
> > the
> > > service location in code, and obviously I can add a new service port
> > > dynamically (Service.addPort) to make it work. But that's not the
> point;
> > I
> > > believe the spec says the schemaLocation is only a hint and
> furthermore,
> > I
> > > should be able to use the service without forced validation, don't you
> > > think?
> > >
> > > Kalle
> > >
> > >
> > > Am Samstag, den 22.03.2008, 16:28 -0700 schrieb Kalle Korhonen:
> > > > > Hello cxfers,
> > > > >
> > > > > I'm trying to consume some web service with jaxws/cxf. I use
> > > > Service.create(new
> > > > > URL("http://some.server/service?wsdl"), SERVICE_NAME). The
> service's
> > > > wsdl
> > > > > imports xsd with a relative schemaLocation (e.g xsd:import
> > > > > namespace="servicens" schemaLocation="servicens.xsd") , but the
> > .xsds
> > > > are
> > > > > not available through the server (from
> > http://some.server/servicens.xsd),
> > > > so
> > > > > constructing the service (client) fails with
> FileNotFoundException.
> > I
> > > > have
> > > > > the xsds but I don't know how to tell cxf's servicefactory where
> the
> > > > xsds
> > > > > are located. I've seen quite a few other threads on the list
> related
> > to
> > > > > resolving references to xsds but the service is not mine so I
> cannot
> > > > change
> > > > > the references or make the xsds available on the server. If I
> point
> > to a
> > > > > local wsdl, the service factory doesn't even try to resolve the
> > schemas;
> > > > > probably because it's setting the validation off, but I don't know
> > how
> > > > to
> > > > > control that. Anybody able to help me?
> > > > >
> > > > > Kalle
> > > >
> > > >
> >
> >
>

Re: Override schemalocation when creating a client

Posted by Kalle Korhonen <ka...@gmail.com>.
On Sun, Mar 23, 2008 at 4:50 PM, Glen Mazza <gl...@verizon.net> wrote:

> I have not coded that way before, nor needed to.  Can you not just set
> the ENDPOINT_ADDRESS_PROPERTY as done here[1], step #7?


That would work, but I don't think it's any easier or more correct than:
        QName newServicePort = new QName("urn:some:service", "newport");
        service.addPort(newServicePort,
javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING,"http://newserver/service
");
        servicePort = service.getPort(newServicePort, ServiceInterface.class
);

Otherwise, the JAX WS 2.1 specification, in Section 5.2.5.4
> ("Application-Specified Service") seems to define the manner of making
> web services calls as you do below.  For XSD resolution, it also
> requires using either the "catalog facility" defined in Section 4.4 or
> "metadata documents".  I would guess you would want to create the former
> for your SOAP client calls to work.


Thanks for pointing out section 4.4. I didn't really feel like configuring
the default XML catalog for the xml parser and didn't see any way of
providing custom entity resolvers. Hadn't noticed META-INF/jax-
ws-catalog.xml, that looks exactly like what I was looking for.

Kalle



> Am Sonntag, den 23.03.2008, 14:39 -0700 schrieb Kalle Korhonen:
> > On Sat, Mar 22, 2008 at 10:47 PM, Glen Mazza <gl...@verizon.net>
> wrote:
> >
> > > I'm not sure, but I think you're trying to create a dynamic client
> which
> > > is unfortunately not working for you.  Hopefully someone else can
> answer
> > > your specific question on this, but in the meantime, you might wish to
> > > try the more traditional route of getting the WSDL and XSD's on your
> > > machine locally, running wsdl2java and then coding your SOAP client
> > > using the wsdl2java artifacts generated, similar to here[1].  Once
> done,
> > > any missing XSD's from the server should no longer be a concern for
> you.
> > >
> >
> > But it is a concern. I have the generated service stubs, but if I create
> the
> > service by specifying the the server url (Service.create(new
> > URL("http://<http://some.server/service?wsdl>..."),
> > it'll try to fetch the xsds and fails because of that. The same doesn't
> > happen if I point to a wsdl from classpath. I need to be able to specify
> the
> > service location in code, and obviously I can add a new service port
> > dynamically (Service.addPort) to make it work. But that's not the point;
> I
> > believe the spec says the schemaLocation is only a hint and furthermore,
> I
> > should be able to use the service without forced validation, don't you
> > think?
> >
> > Kalle
> >
> >
> > Am Samstag, den 22.03.2008, 16:28 -0700 schrieb Kalle Korhonen:
> > > > Hello cxfers,
> > > >
> > > > I'm trying to consume some web service with jaxws/cxf. I use
> > > Service.create(new
> > > > URL("http://some.server/service?wsdl"), SERVICE_NAME). The service's
> > > wsdl
> > > > imports xsd with a relative schemaLocation (e.g xsd:import
> > > > namespace="servicens" schemaLocation="servicens.xsd") , but the
> .xsds
> > > are
> > > > not available through the server (from
> http://some.server/servicens.xsd),
> > > so
> > > > constructing the service (client) fails with FileNotFoundException.
> I
> > > have
> > > > the xsds but I don't know how to tell cxf's servicefactory where the
> > > xsds
> > > > are located. I've seen quite a few other threads on the list related
> to
> > > > resolving references to xsds but the service is not mine so I cannot
> > > change
> > > > the references or make the xsds available on the server. If I point
> to a
> > > > local wsdl, the service factory doesn't even try to resolve the
> schemas;
> > > > probably because it's setting the validation off, but I don't know
> how
> > > to
> > > > control that. Anybody able to help me?
> > > >
> > > > Kalle
> > >
> > >
>
>

Re: Override schemalocation when creating a client

Posted by Glen Mazza <gl...@verizon.net>.
I have not coded that way before, nor needed to.  Can you not just set
the ENDPOINT_ADDRESS_PROPERTY as done here[1], step #7?

Otherwise, the JAX WS 2.1 specification, in Section 5.2.5.4
("Application-Specified Service") seems to define the manner of making
web services calls as you do below.  For XSD resolution, it also
requires using either the "catalog facility" defined in Section 4.4 or
"metadata documents".  I would guess you would want to create the former
for your SOAP client calls to work.

HTH,
Glen

[1] http://www.jroller.com/gmazza/entry/using_the_ebay_shopping_api1

Am Sonntag, den 23.03.2008, 14:39 -0700 schrieb Kalle Korhonen:
> On Sat, Mar 22, 2008 at 10:47 PM, Glen Mazza <gl...@verizon.net> wrote:
> 
> > I'm not sure, but I think you're trying to create a dynamic client which
> > is unfortunately not working for you.  Hopefully someone else can answer
> > your specific question on this, but in the meantime, you might wish to
> > try the more traditional route of getting the WSDL and XSD's on your
> > machine locally, running wsdl2java and then coding your SOAP client
> > using the wsdl2java artifacts generated, similar to here[1].  Once done,
> > any missing XSD's from the server should no longer be a concern for you.
> >
> 
> But it is a concern. I have the generated service stubs, but if I create the
> service by specifying the the server url (Service.create(new
> URL("http://<http://some.server/service?wsdl>..."),
> it'll try to fetch the xsds and fails because of that. The same doesn't
> happen if I point to a wsdl from classpath. I need to be able to specify the
> service location in code, and obviously I can add a new service port
> dynamically (Service.addPort) to make it work. But that's not the point; I
> believe the spec says the schemaLocation is only a hint and furthermore, I
> should be able to use the service without forced validation, don't you
> think?
> 
> Kalle
> 
> 
> Am Samstag, den 22.03.2008, 16:28 -0700 schrieb Kalle Korhonen:
> > > Hello cxfers,
> > >
> > > I'm trying to consume some web service with jaxws/cxf. I use
> > Service.create(new
> > > URL("http://some.server/service?wsdl"), SERVICE_NAME). The service's
> > wsdl
> > > imports xsd with a relative schemaLocation (e.g xsd:import
> > > namespace="servicens" schemaLocation="servicens.xsd") , but the .xsds
> > are
> > > not available through the server (from http://some.server/servicens.xsd),
> > so
> > > constructing the service (client) fails with FileNotFoundException. I
> > have
> > > the xsds but I don't know how to tell cxf's servicefactory where the
> > xsds
> > > are located. I've seen quite a few other threads on the list related to
> > > resolving references to xsds but the service is not mine so I cannot
> > change
> > > the references or make the xsds available on the server. If I point to a
> > > local wsdl, the service factory doesn't even try to resolve the schemas;
> > > probably because it's setting the validation off, but I don't know how
> > to
> > > control that. Anybody able to help me?
> > >
> > > Kalle
> >
> >


Re: Override schemalocation when creating a client

Posted by Jervis Liu <je...@gmail.com>.
On Mon, Mar 24, 2008 at 1:00 PM, Kalle Korhonen <ka...@gmail.com>
wrote:

> On Sun, Mar 23, 2008 at 7:57 PM, Jervis Liu <je...@gmail.com> wrote:
>
> > On Mon, Mar 24, 2008 at 5:39 AM, Kalle Korhonen <
> > kalle.o.korhonen@gmail.com>
> > > On Sat, Mar 22, 2008 at 10:47 PM, Glen Mazza <gl...@verizon.net>
> > > > machine locally, running wsdl2java and then coding your SOAP client
> > > > using the wsdl2java artifacts generated, similar to here[1].  Once
> > done,
> > > > any missing XSD's from the server should no longer be a concern for
> > you.
> > > But it is a concern. I have the generated service stubs, but if I
> create
> > > service by specifying the the server url (Service.create(new
> > > URL("http://<http://some.server/service?wsdl>..."),
> > > it'll try to fetch the xsds and fails because of that. The same
> doesn't
> > > happen if I point to a wsdl from classpath. I need to be able to
> specify
> > > the
> > > service location in code,
> >
> > You've got it almost right. You need to point your client to use a local
> > copy of wsdl file and xsds etc. But you do not need to hard code the
> wsdl
> > location in your client. Take a look into any CXF sample, for example,
> > samples\hello_world. You can see the WSDL location is passed in from
> > command
> > line or from ant script as below:
> >
>
> I think you misunderstood what we are talking about here; not the the wsdl
> location but the location of the service (port) (and originally, how
> references to imported resources can and should be resolved).


I thought the problem you ran into is that the service your client wants to
consume somehow does not come with xsds. Then you work around this by using
a local copy of WSDL and xsds. You do not need to reset endpoint address as
long as you have set it correclty in your local WSDL, e.g "<http:address
location="http://localhost:9000/XMLService/XMLPort"/>". In case you want to
override endpoint address, you can use ENDPOINT_ADDRESS_PROPERTY as this is
the most standard way to do it.

Another thing is that I dont think you need to use Service.create(new
URL("http://<http://some.server/service?wsdl>..."). You have run wsdltojava
to generate client stubs, havent you? A concrete service implementation
class should have been generated by wsdltojava (per JAX-WS 2.1 spec 4.1.1.2,
Static case), its easier to use this class directly instead of using
Service.create(). eg:

        StockQuoteService ss = new StockQuoteService(wsdlURL, serviceQname);
        Greeter port = ss.getSoapPort();

other than
        Service ss = Service.create(new URL("http://<
http://some.server/service?wsdl>", serviceQname);
        Greeter port = (Greeter)ss.getPort(....);

Having said that, the StockQuoteService indeed calls Service.create(...)
internally. So if you really want to use Service.create(...) direclty, just
make sure you provide it with a local copy of wsdl, also make sure the
endpoint address in your local wsdl is correct.

Cheers,
Jervis

>
> Kalle
>

Re: Override schemalocation when creating a client

Posted by Kalle Korhonen <ka...@gmail.com>.
On Sun, Mar 23, 2008 at 7:57 PM, Jervis Liu <je...@gmail.com> wrote:

> On Mon, Mar 24, 2008 at 5:39 AM, Kalle Korhonen <
> kalle.o.korhonen@gmail.com>
> > On Sat, Mar 22, 2008 at 10:47 PM, Glen Mazza <gl...@verizon.net>
> > > machine locally, running wsdl2java and then coding your SOAP client
> > > using the wsdl2java artifacts generated, similar to here[1].  Once
> done,
> > > any missing XSD's from the server should no longer be a concern for
> you.
> > But it is a concern. I have the generated service stubs, but if I create
> > service by specifying the the server url (Service.create(new
> > URL("http://<http://some.server/service?wsdl>..."),
> > it'll try to fetch the xsds and fails because of that. The same doesn't
> > happen if I point to a wsdl from classpath. I need to be able to specify
> > the
> > service location in code,
>
> You've got it almost right. You need to point your client to use a local
> copy of wsdl file and xsds etc. But you do not need to hard code the wsdl
> location in your client. Take a look into any CXF sample, for example,
> samples\hello_world. You can see the WSDL location is passed in from
> command
> line or from ant script as below:
>

I think you misunderstood what we are talking about here; not the the wsdl
location but the location of the service (port) (and originally, how
references to imported resources can and should be resolved).

Kalle

Re: Override schemalocation when creating a client

Posted by Jervis Liu <je...@gmail.com>.
Hi Kalle, comment in-line.

Cheers,
Jervis

On Mon, Mar 24, 2008 at 5:39 AM, Kalle Korhonen <ka...@gmail.com>
wrote:

> On Sat, Mar 22, 2008 at 10:47 PM, Glen Mazza <gl...@verizon.net>
> wrote:
>
> > I'm not sure, but I think you're trying to create a dynamic client which
> > is unfortunately not working for you.  Hopefully someone else can answer
> > your specific question on this, but in the meantime, you might wish to
> > try the more traditional route of getting the WSDL and XSD's on your
> > machine locally, running wsdl2java and then coding your SOAP client
> > using the wsdl2java artifacts generated, similar to here[1].  Once done,
> > any missing XSD's from the server should no longer be a concern for you.
> >
>
> But it is a concern. I have the generated service stubs, but if I create
> the
> service by specifying the the server url (Service.create(new
> URL("http://<http://some.server/service?wsdl>..."),
> it'll try to fetch the xsds and fails because of that. The same doesn't
> happen if I point to a wsdl from classpath. I need to be able to specify
> the
> service location in code,


You've got it almost right. You need to point your client to use a local
copy of wsdl file and xsds etc. But you do not need to hard code the wsdl
location in your client. Take a look into any CXF sample, for example,
samples\hello_world. You can see the WSDL location is passed in from command
line or from ant script as below:

    public static void main(String args[]) throws Exception {

        if (args.length == 0) {
            System.out.println("please specify wsdl");
            System.exit(1);
        }

        URL wsdlURL;
        File wsdlFile = new File(args[0]);
        if (wsdlFile.exists()) {
            wsdlURL = wsdlFile.toURL();
        } else {
            wsdlURL = new URL(args[0]);
        }

        System.out.println(wsdlURL);
        SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
        Greeter port = ss.getSoapPort();

        .........
      }


> and obviously I can add a new service port
> dynamically (Service.addPort) to make it work. But that's not the point; I
> believe the spec says the schemaLocation is only a hint and furthermore, I
> should be able to use the service without forced validation, don't you
> think?
>
> Kalle
>
>
> Am Samstag, den 22.03.2008, 16:28 -0700 schrieb Kalle Korhonen:
> > > Hello cxfers,
> > >
> > > I'm trying to consume some web service with jaxws/cxf. I use
> > Service.create(new
> > > URL("http://some.server/service?wsdl"), SERVICE_NAME). The service's
> > wsdl
> > > imports xsd with a relative schemaLocation (e.g xsd:import
> > > namespace="servicens" schemaLocation="servicens.xsd") , but the .xsds
> > are
> > > not available through the server (from
> http://some.server/servicens.xsd),
> > so
> > > constructing the service (client) fails with FileNotFoundException. I
> > have
> > > the xsds but I don't know how to tell cxf's servicefactory where the
> > xsds
> > > are located. I've seen quite a few other threads on the list related
> to
> > > resolving references to xsds but the service is not mine so I cannot
> > change
> > > the references or make the xsds available on the server. If I point to
> a
> > > local wsdl, the service factory doesn't even try to resolve the
> schemas;
> > > probably because it's setting the validation off, but I don't know how
> > to
> > > control that. Anybody able to help me?
> > >
> > > Kalle
> >
> >
>

Re: Override schemalocation when creating a client

Posted by Kalle Korhonen <ka...@gmail.com>.
On Sat, Mar 22, 2008 at 10:47 PM, Glen Mazza <gl...@verizon.net> wrote:

> I'm not sure, but I think you're trying to create a dynamic client which
> is unfortunately not working for you.  Hopefully someone else can answer
> your specific question on this, but in the meantime, you might wish to
> try the more traditional route of getting the WSDL and XSD's on your
> machine locally, running wsdl2java and then coding your SOAP client
> using the wsdl2java artifacts generated, similar to here[1].  Once done,
> any missing XSD's from the server should no longer be a concern for you.
>

But it is a concern. I have the generated service stubs, but if I create the
service by specifying the the server url (Service.create(new
URL("http://<http://some.server/service?wsdl>..."),
it'll try to fetch the xsds and fails because of that. The same doesn't
happen if I point to a wsdl from classpath. I need to be able to specify the
service location in code, and obviously I can add a new service port
dynamically (Service.addPort) to make it work. But that's not the point; I
believe the spec says the schemaLocation is only a hint and furthermore, I
should be able to use the service without forced validation, don't you
think?

Kalle


Am Samstag, den 22.03.2008, 16:28 -0700 schrieb Kalle Korhonen:
> > Hello cxfers,
> >
> > I'm trying to consume some web service with jaxws/cxf. I use
> Service.create(new
> > URL("http://some.server/service?wsdl"), SERVICE_NAME). The service's
> wsdl
> > imports xsd with a relative schemaLocation (e.g xsd:import
> > namespace="servicens" schemaLocation="servicens.xsd") , but the .xsds
> are
> > not available through the server (from http://some.server/servicens.xsd),
> so
> > constructing the service (client) fails with FileNotFoundException. I
> have
> > the xsds but I don't know how to tell cxf's servicefactory where the
> xsds
> > are located. I've seen quite a few other threads on the list related to
> > resolving references to xsds but the service is not mine so I cannot
> change
> > the references or make the xsds available on the server. If I point to a
> > local wsdl, the service factory doesn't even try to resolve the schemas;
> > probably because it's setting the validation off, but I don't know how
> to
> > control that. Anybody able to help me?
> >
> > Kalle
>
>

Re: Override schemalocation when creating a client

Posted by Glen Mazza <gl...@verizon.net>.
I'm not sure, but I think you're trying to create a dynamic client which
is unfortunately not working for you.  Hopefully someone else can answer
your specific question on this, but in the meantime, you might wish to
try the more traditional route of getting the WSDL and XSD's on your
machine locally, running wsdl2java and then coding your SOAP client
using the wsdl2java artifacts generated, similar to here[1].  Once done,
any missing XSD's from the server should no longer be a concern for you.

HTH,
Glen

[1] http://www.jroller.com/gmazza/date/20070929


Am Samstag, den 22.03.2008, 16:28 -0700 schrieb Kalle Korhonen:
> Hello cxfers,
> 
> I'm trying to consume some web service with jaxws/cxf. I use Service.create(new
> URL("http://some.server/service?wsdl"), SERVICE_NAME). The service's wsdl
> imports xsd with a relative schemaLocation (e.g xsd:import
> namespace="servicens" schemaLocation="servicens.xsd") , but the .xsds are
> not available through the server (from http://some.server/servicens.xsd), so
> constructing the service (client) fails with FileNotFoundException. I have
> the xsds but I don't know how to tell cxf's servicefactory where the xsds
> are located. I've seen quite a few other threads on the list related to
> resolving references to xsds but the service is not mine so I cannot change
> the references or make the xsds available on the server. If I point to a
> local wsdl, the service factory doesn't even try to resolve the schemas;
> probably because it's setting the validation off, but I don't know how to
> control that. Anybody able to help me?
> 
> Kalle