You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Shafi_WS <sh...@sonata-software.com> on 2013/03/13 13:51:17 UTC
Error When Generating Client
Hi,
I am getting the error when generating Client.
following is the code, appreciate if anyone help quickly.
URL url = new URL("http://bg4ws0099:7047/DynamicsNAV/WS/Services");
JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory
.newInstance();
Client client = clientFactory.createClient(url.toExternalForm());
Exception:
Exception in thread "main"
org.apache.cxf.service.factory.ServiceConstructionException: Failed to
create service.
at
org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:86)
at
org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:292)
at
org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:235)
at
org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:228)
at
org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:183)
at com.test.DemoWebService.main(DemoWebService.java:21)
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR:
Problem parsing 'http://bg4ws0099:7047/DynamicsNAV/WS/Services'.:
java.io.IOException: Server returned HTTP response code: 401 for URL:
http://bg4ws0099:7047/DynamicsNAV/WS/Services
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at
org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:262)
at
org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:205)
at
org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:84)
... 5 more
Caused by: java.io.IOException: Server returned HTTP response code: 401 for
URL: http://bg4ws0099:7047/DynamicsNAV/WS/Services
--
View this message in context: http://cxf.547215.n5.nabble.com/Error-When-Generating-Client-tp5724501.html
Sent from the cxf-dev mailing list archive at Nabble.com.
Re: Error When Generating Client
Posted by Shafi_WS <sh...@sonata-software.com>.
here is the complete code after setting the User credentials
URL url = new URL("http://bg4ws0099:7047/DynamicsNAV/WS/Services");
JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory
.newInstance();
Client client = clientFactory.createClient(url.toExternalForm());
HTTPConduit http = (HTTPConduit) client.getConduit();
AuthorizationPolicy policy = new AuthorizationPolicy();
policy.setUserName("newuser1");
policy.setPassword("calling123");
http.setAuthorization(policy);
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(60000);
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(60000);
http.setClient(httpClientPolicy);
Object[] responseArray = null;
try {
responseArray = client.invoke("Read", new String("10000"));
} catch (Exception e) {
System.out.println("EXCEPTION is " + e.getCause());
System.out.println("EXCEPTION is " + e);
}
System.out.println(responseArray[0]);
--
View this message in context: http://cxf.547215.n5.nabble.com/Error-When-Generating-Client-tp5724501p5724502.html
Sent from the cxf-dev mailing list archive at Nabble.com.
Re: Error When Generating Client
Posted by Freeman Fang <fr...@gmail.com>.
Hi,
HTTP 401 is Unauthorized error, which means the URL "http://bg4ws0099:7047/DynamicsNAV/WS/Services" you try to access need auth(username/password), You need configure http conduit with username/password for JaxWsDynamicClientFactory to access that URL, take a look at related discussion[1] to know how
[1]http://cxf.547215.n5.nabble.com/Retrive-WSDL-using-basic-authentication-td5724416.html
-------------
Freeman(Yue) Fang
Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋
On 2013-3-13, at 下午8:51, Shafi_WS wrote:
> Hi,
>
> I am getting the error when generating Client.
>
> following is the code, appreciate if anyone help quickly.
>
> URL url = new URL("http://bg4ws0099:7047/DynamicsNAV/WS/Services");
>
> JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory
> .newInstance();
>
> Client client = clientFactory.createClient(url.toExternalForm());
>
>
> Exception:
>
>
> Exception in thread "main"
> org.apache.cxf.service.factory.ServiceConstructionException: Failed to
> create service.
> at
> org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:86)
> at
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:292)
> at
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:235)
> at
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:228)
> at
> org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:183)
> at com.test.DemoWebService.main(DemoWebService.java:21)
> Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR:
> Problem parsing 'http://bg4ws0099:7047/DynamicsNAV/WS/Services'.:
> java.io.IOException: Server returned HTTP response code: 401 for URL:
> http://bg4ws0099:7047/DynamicsNAV/WS/Services
> at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
> at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
> at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
> at
> org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:262)
> at
> org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:205)
> at
> org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:84)
> ... 5 more
> Caused by: java.io.IOException: Server returned HTTP response code: 401 for
> URL: http://bg4ws0099:7047/DynamicsNAV/WS/Services
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Error-When-Generating-Client-tp5724501.html
> Sent from the cxf-dev mailing list archive at Nabble.com.