Re: [Resteasy-users] POST method always returns "Error status 401 Unauthorized"

2013-10-15 Thread Nuwan Bandara
Thanks for all the responses. Much appreciated.

I executed the same code I've posted in the question from my home network
(no firewall) and I was able to reach the server. However when I use the
same code from the office networks I still get the 401 issue. This
indicates that office firewall/network has some sort of restriction that
does not allow me to call the 3rd party web service URL. Assuming this is
the reason for the issue I'm working with the office network guys to solve
it. Hope this will fix the issue.


On Mon, Oct 14, 2013 at 4:47 PM, William Antônio Siqueira <
william.a.sique...@gmail.com> wrote:

> You should configure the proxy on the underlying Http Client
>
>
> http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
>
>
>
> --
> *William Antônio Siqueira*
> *Java Support Analyst*
> *
> *
> *http://fxapps.blogspot.com*
> *http://www.williamantonio.wordpress.com*
> *http://williamprogrammer.com*
>
>
> 2013/10/14 Nuwan Bandara 
>
>> API does not required a authentication.
>>
>> I'm keep on getting
>>
>> "533 [main] INFO
>> org.apache.commons.httpclient.auth.AuthChallengeProcessor - basic
>> authentication scheme selected
>> 535 [main] INFO org.apache.commons.httpclient.HttpMethodDirector - No
>> credentials available for BASIC 'Quest Diagnostics (QDC) Internet '@
>> www.google.com:80"
>>
>> Is it because I'm behind a firewall and I'm not allowed to call out side
>> (3rd party) web services?
>>
>>
>>
>> On Mon, Oct 14, 2013 at 12:13 PM, Bill Burke  wrote:
>>
>>> Maybe because your REST service requires authentication?
>>>
>>> On 10/14/2013 2:54 PM, Nuwan Bandara wrote:
>>> > Can someone help me on this?
>>> >
>>> > Thanks.
>>> >
>>> >
>>> > On Fri, Oct 11, 2013 at 1:15 PM, Nuwan Bandara >> > > wrote:
>>> >
>>> > Hi,
>>> >
>>> > I use the following code to call a web service using POST and
>>> always
>>> > get "POST method always returns "Error status 401 Unauthorized""
>>> >
>>> > Can someone help me to figure out what I do wrong in the bellow
>>> code?
>>> >
>>> > Thanks in advance,
>>> > Nuwan
>>> >
>>> >
>>> > *FYI: webServiceUrl:
>>> >
>>> http://apitest.collabrx.com/oncovar/V1-0-7?client_id=XXX&command=submit_sample*
>>> >
>>> >  public Document post(String webServiceUrl, String data) throws
>>> > ExternalResourceConnectorException {
>>> >  logger.debug("Posting data to URL: " + webServiceUrl);
>>> >  SAXReader saxReader = new SAXReader();
>>> >  Document document = null;
>>> >  StringBuffer responseMsg = new StringBuffer();
>>> >  try {
>>> >  ClientRequest request = new
>>> ClientRequest(webServiceUrl);
>>> >  request.accept("application/xml");
>>> >  request.body(MediaType.APPLICATION_XML, data); // data
>>> > to be identified.
>>> >  ClientResponse response =
>>> > request.post(String.class);
>>> >  //Object response =  request.post().getEntity(new
>>> > GenericType(){});
>>> >  if (response.getStatus() != 200) {
>>> >  throw new RuntimeException("Failed : HTTP error
>>> > code : " + response.getStatus());
>>> >  }
>>> >  BufferedReader br = new BufferedReader(new
>>> > InputStreamReader(new ByteArrayInputStream(response.getEntity()
>>> >  .getBytes(;
>>> >  String output;
>>> >  while ((output = br.readLine()) != null) {
>>> >  responseMsg.append(output);
>>> >  }
>>> > logger.info ("External web service response:
>>> "+
>>> > responseMsg.toString());
>>> >  document = saxReader.read(new
>>> > StringReader(responseMsg.toString()));
>>> >  }
>>> >  catch (ClientProtocolException e) {
>>> >  throw new ExternalResourceConnectorException(e);
>>> >  }
>>> >  catch (IOException e) {
>>> >  throw new ExternalResourceConnectorException(e);
>>> >  }
>>> >  catch (Exception e) {
>>> >  throw new ExternalResourceConnectorException(e);
>>> >  }
>>> >  return document;
>>> >  }
>>> >
>>> >
>>> >
>>> >
>>> >
>>> --
>>> > October Webinars: Code for Performance
>>> > Free Intel webinars can help you accelerate application performance.
>>> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the
>>> most from
>>> > the latest Intel processors and coprocessors. See abstracts and
>>> register >
>>> >
>>> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
>>> >
>>> >
>>> >
>>> > ___
>>> > Reste

Re: [Resteasy-users] POST method always returns "Error status 401 Unauthorized"

2013-10-14 Thread William Antônio Siqueira
You should configure the proxy on the underlying Http Client

http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientProxyAuthentication.java



--
*William Antônio Siqueira*
*Java Support Analyst*
*
*
*http://fxapps.blogspot.com*
*http://www.williamantonio.wordpress.com*
*http://williamprogrammer.com*


2013/10/14 Nuwan Bandara 

> API does not required a authentication.
>
> I'm keep on getting
>
> "533 [main] INFO org.apache.commons.httpclient.auth.AuthChallengeProcessor
> - basic authentication scheme selected
> 535 [main] INFO org.apache.commons.httpclient.HttpMethodDirector - No
> credentials available for BASIC 'Quest Diagnostics (QDC) Internet '@
> www.google.com:80"
>
> Is it because I'm behind a firewall and I'm not allowed to call out side
> (3rd party) web services?
>
>
>
> On Mon, Oct 14, 2013 at 12:13 PM, Bill Burke  wrote:
>
>> Maybe because your REST service requires authentication?
>>
>> On 10/14/2013 2:54 PM, Nuwan Bandara wrote:
>> > Can someone help me on this?
>> >
>> > Thanks.
>> >
>> >
>> > On Fri, Oct 11, 2013 at 1:15 PM, Nuwan Bandara > > > wrote:
>> >
>> > Hi,
>> >
>> > I use the following code to call a web service using POST and always
>> > get "POST method always returns "Error status 401 Unauthorized""
>> >
>> > Can someone help me to figure out what I do wrong in the bellow
>> code?
>> >
>> > Thanks in advance,
>> > Nuwan
>> >
>> >
>> > *FYI: webServiceUrl:
>> >
>> http://apitest.collabrx.com/oncovar/V1-0-7?client_id=XXX&command=submit_sample*
>> >
>> >  public Document post(String webServiceUrl, String data) throws
>> > ExternalResourceConnectorException {
>> >  logger.debug("Posting data to URL: " + webServiceUrl);
>> >  SAXReader saxReader = new SAXReader();
>> >  Document document = null;
>> >  StringBuffer responseMsg = new StringBuffer();
>> >  try {
>> >  ClientRequest request = new
>> ClientRequest(webServiceUrl);
>> >  request.accept("application/xml");
>> >  request.body(MediaType.APPLICATION_XML, data); // data
>> > to be identified.
>> >  ClientResponse response =
>> > request.post(String.class);
>> >  //Object response =  request.post().getEntity(new
>> > GenericType(){});
>> >  if (response.getStatus() != 200) {
>> >  throw new RuntimeException("Failed : HTTP error
>> > code : " + response.getStatus());
>> >  }
>> >  BufferedReader br = new BufferedReader(new
>> > InputStreamReader(new ByteArrayInputStream(response.getEntity()
>> >  .getBytes(;
>> >  String output;
>> >  while ((output = br.readLine()) != null) {
>> >  responseMsg.append(output);
>> >  }
>> > logger.info ("External web service response: "+
>> > responseMsg.toString());
>> >  document = saxReader.read(new
>> > StringReader(responseMsg.toString()));
>> >  }
>> >  catch (ClientProtocolException e) {
>> >  throw new ExternalResourceConnectorException(e);
>> >  }
>> >  catch (IOException e) {
>> >  throw new ExternalResourceConnectorException(e);
>> >  }
>> >  catch (Exception e) {
>> >  throw new ExternalResourceConnectorException(e);
>> >  }
>> >  return document;
>> >  }
>> >
>> >
>> >
>> >
>> >
>> --
>> > October Webinars: Code for Performance
>> > Free Intel webinars can help you accelerate application performance.
>> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the
>> most from
>> > the latest Intel processors and coprocessors. See abstracts and
>> register >
>> >
>> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
>> >
>> >
>> >
>> > ___
>> > Resteasy-users mailing list
>> > Resteasy-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/resteasy-users
>> >
>>
>> --
>> Bill Burke
>> JBoss, a division of Red Hat
>> http://bill.burkecentral.com
>>
>>
>> --
>> October Webinars: Code for Performance
>> Free Intel webinars can help you accelerate application performance.
>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
>> from
>> the latest Intel processors and coprocessors. See abstracts and register >
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
>> ___
>> Resteasy-users mailing list
>> Resteasy-users

Re: [Resteasy-users] POST method always returns "Error status 401 Unauthorized"

2013-10-14 Thread Nuwan Bandara
API does not required a authentication.

I'm keep on getting

"533 [main] INFO org.apache.commons.httpclient.auth.AuthChallengeProcessor
- basic authentication scheme selected
535 [main] INFO org.apache.commons.httpclient.HttpMethodDirector - No
credentials available for BASIC 'Quest Diagnostics (QDC) Internet '@
www.google.com:80"

Is it because I'm behind a firewall and I'm not allowed to call out side
(3rd party) web services?



On Mon, Oct 14, 2013 at 12:13 PM, Bill Burke  wrote:

> Maybe because your REST service requires authentication?
>
> On 10/14/2013 2:54 PM, Nuwan Bandara wrote:
> > Can someone help me on this?
> >
> > Thanks.
> >
> >
> > On Fri, Oct 11, 2013 at 1:15 PM, Nuwan Bandara  > > wrote:
> >
> > Hi,
> >
> > I use the following code to call a web service using POST and always
> > get "POST method always returns "Error status 401 Unauthorized""
> >
> > Can someone help me to figure out what I do wrong in the bellow code?
> >
> > Thanks in advance,
> > Nuwan
> >
> >
> > *FYI: webServiceUrl:
> >
> http://apitest.collabrx.com/oncovar/V1-0-7?client_id=XXX&command=submit_sample*
> >
> >  public Document post(String webServiceUrl, String data) throws
> > ExternalResourceConnectorException {
> >  logger.debug("Posting data to URL: " + webServiceUrl);
> >  SAXReader saxReader = new SAXReader();
> >  Document document = null;
> >  StringBuffer responseMsg = new StringBuffer();
> >  try {
> >  ClientRequest request = new
> ClientRequest(webServiceUrl);
> >  request.accept("application/xml");
> >  request.body(MediaType.APPLICATION_XML, data); // data
> > to be identified.
> >  ClientResponse response =
> > request.post(String.class);
> >  //Object response =  request.post().getEntity(new
> > GenericType(){});
> >  if (response.getStatus() != 200) {
> >  throw new RuntimeException("Failed : HTTP error
> > code : " + response.getStatus());
> >  }
> >  BufferedReader br = new BufferedReader(new
> > InputStreamReader(new ByteArrayInputStream(response.getEntity()
> >  .getBytes(;
> >  String output;
> >  while ((output = br.readLine()) != null) {
> >  responseMsg.append(output);
> >  }
> > logger.info ("External web service response: "+
> > responseMsg.toString());
> >  document = saxReader.read(new
> > StringReader(responseMsg.toString()));
> >  }
> >  catch (ClientProtocolException e) {
> >  throw new ExternalResourceConnectorException(e);
> >  }
> >  catch (IOException e) {
> >  throw new ExternalResourceConnectorException(e);
> >  }
> >  catch (Exception e) {
> >  throw new ExternalResourceConnectorException(e);
> >  }
> >  return document;
> >  }
> >
> >
> >
> >
> >
> --
> > October Webinars: Code for Performance
> > Free Intel webinars can help you accelerate application performance.
> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> > the latest Intel processors and coprocessors. See abstracts and register
> >
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
> >
> >
> >
> > ___
> > Resteasy-users mailing list
> > Resteasy-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/resteasy-users
> >
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
>
> --
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk

Re: [Resteasy-users] POST method always returns "Error status 401 Unauthorized"

2013-10-14 Thread Bill Burke
Maybe because your REST service requires authentication?

On 10/14/2013 2:54 PM, Nuwan Bandara wrote:
> Can someone help me on this?
>
> Thanks.
>
>
> On Fri, Oct 11, 2013 at 1:15 PM, Nuwan Bandara  > wrote:
>
> Hi,
>
> I use the following code to call a web service using POST and always
> get "POST method always returns "Error status 401 Unauthorized""
>
> Can someone help me to figure out what I do wrong in the bellow code?
>
> Thanks in advance,
> Nuwan
>
>
> *FYI: webServiceUrl:
> 
> http://apitest.collabrx.com/oncovar/V1-0-7?client_id=XXX&command=submit_sample*
>
>  public Document post(String webServiceUrl, String data) throws
> ExternalResourceConnectorException {
>  logger.debug("Posting data to URL: " + webServiceUrl);
>  SAXReader saxReader = new SAXReader();
>  Document document = null;
>  StringBuffer responseMsg = new StringBuffer();
>  try {
>  ClientRequest request = new ClientRequest(webServiceUrl);
>  request.accept("application/xml");
>  request.body(MediaType.APPLICATION_XML, data); // data
> to be identified.
>  ClientResponse response =
> request.post(String.class);
>  //Object response =  request.post().getEntity(new
> GenericType(){});
>  if (response.getStatus() != 200) {
>  throw new RuntimeException("Failed : HTTP error
> code : " + response.getStatus());
>  }
>  BufferedReader br = new BufferedReader(new
> InputStreamReader(new ByteArrayInputStream(response.getEntity()
>  .getBytes(;
>  String output;
>  while ((output = br.readLine()) != null) {
>  responseMsg.append(output);
>  }
> logger.info ("External web service response: "+
> responseMsg.toString());
>  document = saxReader.read(new
> StringReader(responseMsg.toString()));
>  }
>  catch (ClientProtocolException e) {
>  throw new ExternalResourceConnectorException(e);
>  }
>  catch (IOException e) {
>  throw new ExternalResourceConnectorException(e);
>  }
>  catch (Exception e) {
>  throw new ExternalResourceConnectorException(e);
>  }
>  return document;
>  }
>
>
>
>
> --
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
>
>
>
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] POST method always returns "Error status 401 Unauthorized"

2013-10-14 Thread Nuwan Bandara
Can someone help me on this?

Thanks.


On Fri, Oct 11, 2013 at 1:15 PM, Nuwan Bandara  wrote:

> Hi,
>
> I use the following code to call a web service using POST and always get
> "POST method always returns "Error status 401 Unauthorized""
>
> Can someone help me to figure out what I do wrong in the bellow code?
>
> Thanks in advance,
> Nuwan
>
>
> *FYI: webServiceUrl:
> http://apitest.collabrx.com/oncovar/V1-0-7?client_id=XXX&command=submit_sample
> *
>
> public Document post(String webServiceUrl, String data) throws
> ExternalResourceConnectorException {
> logger.debug("Posting data to URL: " + webServiceUrl);
> SAXReader saxReader = new SAXReader();
> Document document = null;
> StringBuffer responseMsg = new StringBuffer();
> try {
> ClientRequest request = new ClientRequest(webServiceUrl);
> request.accept("application/xml");
> request.body(MediaType.APPLICATION_XML, data); // data to be
> identified.
> ClientResponse response = request.post(String.class);
> //Object response =  request.post().getEntity(new
> GenericType(){});
> if (response.getStatus() != 200) {
> throw new RuntimeException("Failed : HTTP error code : " +
> response.getStatus());
> }
> BufferedReader br = new BufferedReader(new
> InputStreamReader(new ByteArrayInputStream(response.getEntity()
> .getBytes(;
> String output;
> while ((output = br.readLine()) != null) {
> responseMsg.append(output);
> }
> logger.info("External web service response: "+
> responseMsg.toString());
> document = saxReader.read(new
> StringReader(responseMsg.toString()));
> }
> catch (ClientProtocolException e) {
> throw new ExternalResourceConnectorException(e);
> }
> catch (IOException e) {
> throw new ExternalResourceConnectorException(e);
> }
> catch (Exception e) {
> throw new ExternalResourceConnectorException(e);
> }
> return document;
> }
>
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] POST method always returns "Error status 401 Unauthorized"

2013-10-11 Thread Nuwan Bandara
Hi,

I use the following code to call a web service using POST and always get
"POST method always returns "Error status 401 Unauthorized""

Can someone help me to figure out what I do wrong in the bellow code?

Thanks in advance,
Nuwan


*FYI: webServiceUrl:
http://apitest.collabrx.com/oncovar/V1-0-7?client_id=XXX&command=submit_sample
*

public Document post(String webServiceUrl, String data) throws
ExternalResourceConnectorException {
logger.debug("Posting data to URL: " + webServiceUrl);
SAXReader saxReader = new SAXReader();
Document document = null;
StringBuffer responseMsg = new StringBuffer();
try {
ClientRequest request = new ClientRequest(webServiceUrl);
request.accept("application/xml");
request.body(MediaType.APPLICATION_XML, data); // data to be
identified.
ClientResponse response = request.post(String.class);
//Object response =  request.post().getEntity(new
GenericType(){});
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : " +
response.getStatus());
}
BufferedReader br = new BufferedReader(new
InputStreamReader(new ByteArrayInputStream(response.getEntity()
.getBytes(;
String output;
while ((output = br.readLine()) != null) {
responseMsg.append(output);
}
logger.info("External web service response: "+
responseMsg.toString());
document = saxReader.read(new
StringReader(responseMsg.toString()));
}
catch (ClientProtocolException e) {
throw new ExternalResourceConnectorException(e);
}
catch (IOException e) {
throw new ExternalResourceConnectorException(e);
}
catch (Exception e) {
throw new ExternalResourceConnectorException(e);
}
return document;
}
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users