You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by bhaskerhari <bh...@yahoo.com> on 2013/07/26 16:21:26 UTC

CXF client with JaxWsProxyFactoryBean without WSDL is throwing ServiceConstructionException

I am trying to use JaxWSProxyFactoryBean without providing the wsdl location. 

        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(MyService.class);
        factory.setAddress(myServiceUrl);

        JAXBDataBinding jaxBDataBinding = new JAXBDataBinding();
        jaxBDataBinding.setContext(myCustomJAXBContext);
        factory.setDataBinding(jaxBDataBinding);

        MyService stub = factory.create(MyService.class);

This piece of code is throwing an exception :- Caused by:
org.apache.cxf.service.factory.ServiceConstructionException: Service class
com.testing.ph.MyService method createOrder part {urn:testing:ph:order}
CreateOrderRequest cannot be mapped to schema. Check for use of a
JAX-WS-specific type without the JAX-WS service factory bean.

If I supply the WSDL URL here, it works absolutely fine (adding the line
factory.setWsdlLocation(wsdlUrl);). But we had an SSLHandShakeException
before when we supplied the wsdllocation. So we had to go without giving the
wsdl url. Any idea what can be done to resolve this error without giving the
WSDL?




--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-client-with-JaxWsProxyFactoryBean-without-WSDL-is-throwing-ServiceConstructionException-tp5731490.html
Sent from the cxf-user mailing list archive at Nabble.com.

RE: CXF client with JaxWsProxyFactoryBean without WSDL is throwing ServiceConstructionException

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

> I am trying to use JaxWSProxyFactoryBean without providing the wsdl
> location.
> 
>         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>         factory.setServiceClass(MyService.class);
>         factory.setAddress(myServiceUrl);
> 
>         JAXBDataBinding jaxBDataBinding = new JAXBDataBinding();
>         jaxBDataBinding.setContext(myCustomJAXBContext);
>         factory.setDataBinding(jaxBDataBinding);
> 
>         MyService stub = factory.create(MyService.class);
> 
> This piece of code is throwing an exception :- Caused by:
> org.apache.cxf.service.factory.ServiceConstructionException: Service class
> com.testing.ph.MyService method createOrder part {urn:testing:ph:order}
> CreateOrderRequest cannot be mapped to schema. Check for use of a JAX-
> WS-specific type without the JAX-WS service factory bean.

What is the reason to use custom JAXB context, how you create it?

> If I supply the WSDL URL here, it works absolutely fine (adding the line
> factory.setWsdlLocation(wsdlUrl);). But we had an SSLHandShakeException
> before when we supplied the wsdllocation. So we had to go without giving
> the wsdl url. Any idea what can be done to resolve this error without giving
> the WSDL?

To resolve that you can either 
- package your wsdl with a jar/war and resolve it through classpath instead remote URL
- or configure trust keystore to resolve SSLHandShakeException: http://stackoverflow.com/questions/6659360/how-to-solve-javax-net-ssl-sslhandshakeexception-error

Regards,
Andrei.

> -----Original Message-----
> From: bhaskerhari [mailto:bhaskerhari@yahoo.com]
> Sent: Freitag, 26. Juli 2013 16:21
> To: users@cxf.apache.org
> Subject: CXF client with JaxWsProxyFactoryBean without WSDL is throwing
> ServiceConstructionException
> 
> I am trying to use JaxWSProxyFactoryBean without providing the wsdl
> location.
> 
>         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>         factory.setServiceClass(MyService.class);
>         factory.setAddress(myServiceUrl);
> 
>         JAXBDataBinding jaxBDataBinding = new JAXBDataBinding();
>         jaxBDataBinding.setContext(myCustomJAXBContext);
>         factory.setDataBinding(jaxBDataBinding);
> 
>         MyService stub = factory.create(MyService.class);
> 
> This piece of code is throwing an exception :- Caused by:
> org.apache.cxf.service.factory.ServiceConstructionException: Service class
> com.testing.ph.MyService method createOrder part {urn:testing:ph:order}
> CreateOrderRequest cannot be mapped to schema. Check for use of a JAX-
> WS-specific type without the JAX-WS service factory bean.
> 
> If I supply the WSDL URL here, it works absolutely fine (adding the line
> factory.setWsdlLocation(wsdlUrl);). But we had an SSLHandShakeException
> before when we supplied the wsdllocation. So we had to go without giving
> the wsdl url. Any idea what can be done to resolve this error without giving
> the WSDL?
> 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-client-
> with-JaxWsProxyFactoryBean-without-WSDL-is-throwing-
> ServiceConstructionException-tp5731490.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF client with JaxWsProxyFactoryBean without WSDL is throwing ServiceConstructionException

Posted by Mark Streit <mc...@gmail.com>.
Have you created your client side JAR that contains all the classes to
include also having the WSDL and any XSDs packaged in a /META-INF/wsdl
location - where they are "localized" with the classes that were generated
from them.  This avoids the "over the wire call" to get the WSDL itself.

This thread might help:
http://metro.1045641.n5.nabble.com/JAX-WS-clients-td5709817.html

There is also a wealth of information on JAX-WS client and server
development on Glen Mazza's weblog
http://www.jroller.com/gmazza/entry/blog_article_index

Mark

On Fri, Jul 26, 2013 at 10:21 AM, bhaskerhari <bh...@yahoo.com> wrote:

> I am trying to use JaxWSProxyFactoryBean without providing the wsdl
> location.
>
>         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>         factory.setServiceClass(MyService.class);
>         factory.setAddress(myServiceUrl);
>
>         JAXBDataBinding jaxBDataBinding = new JAXBDataBinding();
>         jaxBDataBinding.setContext(myCustomJAXBContext);
>         factory.setDataBinding(jaxBDataBinding);
>
>         MyService stub = factory.create(MyService.class);
>
> This piece of code is throwing an exception :- Caused by:
> org.apache.cxf.service.factory.ServiceConstructionException: Service class
> com.testing.ph.MyService method createOrder part {urn:testing:ph:order}
> CreateOrderRequest cannot be mapped to schema. Check for use of a
> JAX-WS-specific type without the JAX-WS service factory bean.
>
> If I supply the WSDL URL here, it works absolutely fine (adding the line
> factory.setWsdlLocation(wsdlUrl);). But we had an SSLHandShakeException
> before when we supplied the wsdllocation. So we had to go without giving
> the
> wsdl url. Any idea what can be done to resolve this error without giving
> the
> WSDL?
>
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/CXF-client-with-JaxWsProxyFactoryBean-without-WSDL-is-throwing-ServiceConstructionException-tp5731490.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Re: CXF client with JaxWsProxyFactoryBean without WSDL is throwing ServiceConstructionException

Posted by kalpabas <ka...@yahoo.com>.
Bhaskerhari,

I got something simile issue when I moved my client code from CXF-2.3.5 to
2.7.8. ( Described here
<http://cxf.547215.n5.nabble.com/CXF-2-7-8-Not-recognize-substitutionGroup-Elements-td5744532.html> 
)

I did all what you have described, but could not get it resolved. Finally I
found a way to disable validation:

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
Map<String, Object> props = factory.getProperties();
if(null == props)
{
	props = new HashMap<String, Object>();
}
props.put("soap.no.validate.parts", true);
factory.setProperties(props);

This resolved my issue. 

Thanks,
Kalpa



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-client-with-JaxWsProxyFactoryBean-without-WSDL-is-throwing-ServiceConstructionException-tp5731490p5744544.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF client with JaxWsProxyFactoryBean without WSDL is throwing ServiceConstructionException

Posted by bhaskerhari <bh...@yahoo.com>.
We already supply this "-frontend jaxws21" while running wsdl2java. And we
are using Java6. So dont thik thats an issue. 

Without custom JAXBContext, I get the illegalannotationexception and after
providing custom JAXBContext, I get servicecreationexception as it is
expecting me to provide the wsdl. If i give wsdl url with custom
jaxbcontext, then it works fine. But we really want to avoid setting the
wsdl url, looks like there is no other option. For now, I am using the
property to set schema validation to false (schema-validation-enabled).





--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-client-with-JaxWsProxyFactoryBean-without-WSDL-is-throwing-ServiceConstructionException-tp5731490p5731878.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF client with JaxWsProxyFactoryBean without WSDL is throwing ServiceConstructionException

Posted by Daniel Kulp <dk...@apache.org>.
On Jul 29, 2013, at 1:48 PM, bhaskerhari <bh...@yahoo.com> wrote:

> Thanks for your reply. We foudn that the JAXBContext created by CXF 2.7.5 is
> having an issue. It is throwing IllegalAnnotationsException during the run
> time. The same set of binding classes when used with an older version of CXF
> (2.2.11) works fine. After debugging a bit, i found that new verison of CXF
> when constructs JaxWSProxyFactoryBean is taking more number of classes in
> JAXBContext. So I created the jaxbcontet manually and that seems to work
> fine.

When you run the wsdl2java, you may want to try passing the "-fe jaxws21" flags to see if that helps.   Maybe some of the classes are getting annotations that aren't compatible with the runtime (assuming you are using Java6 at runtime).

If that doesn't help, a test case would be useful.

> We wanted to eliminate giving wsdl while creating the client. But looks like
> we dont have another option than referencing the wsdl. So I guess we will
> have to identify why we are getting a sslhandshake exception?
> 
> Also, another thing i noticed today. The new version of CXF is not accepting
> "|" character anymore. It is throwing java.net.URISyntaxException: Illegal
> character in query at index 646 exception.
> 
> java.net.URI$Parser.fail(URI.java:2810)
> 	java.net.URI$Parser.checkChars(URI.java:2983)
> 	java.net.URI$Parser.parseHierarchical(URI.java:3073)
> 	java.net.URI$Parser.parse(URI.java:3015)
> 	java.net.URI.<init>(URI.java:577)
> 	java.net.URI.create(URI.java:839)
> 
> org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(JavascriptQueryHandler.java:86)
> 
> org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(JavascriptQueryHandler.java:168)
> 
> The same URL worked fine with old version of CXF. Any idea if the new
> version expects some extra configuration to accept such characters?

Can you log a bug for this?   The | character isn't allowed in URL's so behavior would be unpredictable.   I'd certainly encourage you to change your URL to not include it.  That said, the JavascriptQueryHandler.isRecognizedQuery method should be able to just return false for anything it DOESN'T recognize, including invalid URL's.


-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


RE: CXF client with JaxWsProxyFactoryBean without WSDL is throwing ServiceConstructionException

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

> -----Original Message-----
> From: bhaskerhari [mailto:bhaskerhari@yahoo.com]
> Sent: Montag, 29. Juli 2013 19:48
> To: users@cxf.apache.org
> Subject: Re: CXF client with JaxWsProxyFactoryBean without WSDL is
> throwing ServiceConstructionException
> 
> Thanks for your reply. We foudn that the JAXBContext created by CXF 2.7.5 is
> having an issue. It is throwing IllegalAnnotationsException during the run
> time. The same set of binding classes when used with an older version of CXF
> (2.2.11) works fine. After debugging a bit, i found that new verison of CXF
> when constructs JaxWSProxyFactoryBean is taking more number of classes in
> JAXBContext. So I created the jaxbcontet manually and that seems to work
> fine.

Could you create a small test case and open issue for that?

> We wanted to eliminate giving wsdl while creating the client. But looks like
> we dont have another option than referencing the wsdl. So I guess we will
> have to identify why we are getting a sslhandshake exception?

Normally you need WSDL on the client side only if it contains WS-Policy or you need comprehensive schema validation (that is impossible using just JAXB classes).
In all other cases client doesn't require WSDL.

> 
> Also, another thing i noticed today. The new version of CXF is not accepting
> "|" character anymore. It is throwing java.net.URISyntaxException: Illegal
> character in query at index 646 exception.
> 
> java.net.URI$Parser.fail(URI.java:2810)
> 	java.net.URI$Parser.checkChars(URI.java:2983)
> 	java.net.URI$Parser.parseHierarchical(URI.java:3073)
> 	java.net.URI$Parser.parse(URI.java:3015)
> 	java.net.URI.<init>(URI.java:577)
> 	java.net.URI.create(URI.java:839)
> 
> org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(Javascr
> iptQueryHandler.java:86)
> 
> org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(Javascr
> iptQueryHandler.java:168)
> 
> The same URL worked fine with old version of CXF. Any idea if the new
> version expects some extra configuration to accept such characters?
> 

I guess your reference has incorrect URI syntax regarding http://www.ietf.org/rfc/rfc2396.txt . Any chance to fix it on your side (for example through encoded URI)?

Regards,
Andrei.

> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-client-
> with-JaxWsProxyFactoryBean-without-WSDL-is-throwing-
> ServiceConstructionException-tp5731490p5731627.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF client with JaxWsProxyFactoryBean without WSDL is throwing ServiceConstructionException

Posted by bhaskerhari <bh...@yahoo.com>.
Thanks for your reply. We foudn that the JAXBContext created by CXF 2.7.5 is
having an issue. It is throwing IllegalAnnotationsException during the run
time. The same set of binding classes when used with an older version of CXF
(2.2.11) works fine. After debugging a bit, i found that new verison of CXF
when constructs JaxWSProxyFactoryBean is taking more number of classes in
JAXBContext. So I created the jaxbcontet manually and that seems to work
fine.

We wanted to eliminate giving wsdl while creating the client. But looks like
we dont have another option than referencing the wsdl. So I guess we will
have to identify why we are getting a sslhandshake exception?

Also, another thing i noticed today. The new version of CXF is not accepting
"|" character anymore. It is throwing java.net.URISyntaxException: Illegal
character in query at index 646 exception.

java.net.URI$Parser.fail(URI.java:2810)
	java.net.URI$Parser.checkChars(URI.java:2983)
	java.net.URI$Parser.parseHierarchical(URI.java:3073)
	java.net.URI$Parser.parse(URI.java:3015)
	java.net.URI.<init>(URI.java:577)
	java.net.URI.create(URI.java:839)

org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(JavascriptQueryHandler.java:86)

org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(JavascriptQueryHandler.java:168)

The same URL worked fine with old version of CXF. Any idea if the new
version expects some extra configuration to accept such characters?



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-client-with-JaxWsProxyFactoryBean-without-WSDL-is-throwing-ServiceConstructionException-tp5731490p5731627.html
Sent from the cxf-user mailing list archive at Nabble.com.