You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Ryan Zoerner <ry...@gmail.com> on 2011/05/12 10:31:50 UTC

Server output as a result of the CustomInvoker and Client output after parameterization refactoring of Client, CustomerService, and Order

This is follow-up info to the things that I discussed here:
http://cxf.547215.n5.nabble.com/Basic-Http-Demo-and-the-refactoring-that-I-did-in-the-course-of-figuring-out-how-it-worked-td4389413.html

and here:
http://cxf.547215.n5.nabble.com/demo-jaxrs-server-CustomInvoker-td4389484.html

------------------------------------------------
Custom Invoker:
------------------------------------------------
Here is the terminal output from the Server which has registered a
CustomInvoker.

The registration was done in Server.java

here:

Server.java
--------------------------------------------------------------------------------------------------------
...
sf.setInvoker(new CustomInvoker());
...
--------------------------------------------------------------------------------------------------------

and here is the new output:

mvn -Pserver
--------------------------------------------------------------------------------------------------------

There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] >>> exec-maven-plugin:1.2:java (default) @ jax_rs_basic >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2:java (default) @ jax_rs_basic <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2:java (default) @ jax_rs_basic ---
product 323
product 324
product 325
May 12, 2011 3:18:08 AM org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be http://localhost:9000/
May 12, 2011 3:18:09 AM org.eclipse.jetty.util.log.Slf4jLog info
INFO: jetty-7.3.1.v20110307
May 12, 2011 3:18:09 AM org.eclipse.jetty.util.log.Slf4jLog info
INFO: Started SelectChannelConnector@localhost:9000
May 12, 2011 3:18:09 AM org.eclipse.jetty.util.log.Slf4jLog info
INFO: started o.e.j.s.h.ContextHandler{,null}
Server ready...

***
The method about to be invoked
by the CustomInvoker
is named
--->  getCustomerByID
***

----invoking getCustomer, Customer id is: 123

***
The method about to be invoked
by the CustomInvoker
is named
--->  getOrder
***

----invoking getOrder, Order id is: 223
----invoking getProduct with id: 323

***
The method about to be invoked
by the CustomInvoker
is named
--->  getOrder
***

----invoking getOrder, Order id is: 224
----invoking getProduct with id: 324

***
The method about to be invoked
by the CustomInvoker
is named
--->  getOrder
***

----invoking getOrder, Order id is: 225
----invoking getProduct with id: 325

***
The method about to be invoked
by the CustomInvoker
is named
--->  updateCustomer
***

----invoking updateCustomer, Customer name is: Mary

***
The method about to be invoked
by the CustomInvoker
is named
--->  addCustomer
***

----invoking addCustomer, Customer name is: Jack
Server exiting
S:\cxf\distribution\src\main\release\samples\jax_rs\basic>
--------------------------------------------------------------------------------------------------------


I thought that the firewall and administrative settings on this Windows
operating system would prevent me from printing this, but it turns out
that I was incorrect about that.



------------------------------------------------
Client output with refactoring:
------------------------------------------------
Also, so that you can see the results of the refactoring that I mentioned,
I have also included the client output here:

mvn -Pclient
--------------------------------------------------------------------------------------------------------

[INFO] Scanning for projects...
...
[INFO] --- exec-maven-plugin:1.2:java (default) @ jax_rs_basic ---
Sent HTTP GET request to query customer info
http://localhost:9000/customerservice/customers/123
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><Customer><id>123</id><na
me>John</name></Customer>




Sent HTTP GET request to query sub resource product info
http://localhost:9000/customerservice/orders/223/products/323
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><Product><description>pro
duct 323</description><id>323</id></Product>


Sent HTTP GET request to query sub resource product info
http://localhost:9000/customerservice/orders/224/products/324
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><Product><description>pro
duct 324</description><id>324</id></Product>


Sent HTTP GET request to query sub resource product info
http://localhost:9000/customerservice/orders/225/products/325
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><Product><description>pro
duct 325</description><id>325</id></Product>




Sent HTTP PUT request to update customer info
Response status code: 200
Response body:



Sent HTTP POST request to add customer
Response status code: 200
Response body:
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><Customer><id>124</id><na
me>Jack</name></Customer>


S:\cxf\distribution\src\main\release\samples\jax_rs\basic>
--------------------------------------------------------------------------------------------------------


This was the output from the code that I showed, or at least approximately.
I mention
this because in my most recent iteration of changing the Client, I have been
printing
the url contents and url headers explicitly. This helped me figure out more
about
what seems to be the equivalence of an HTTP GET Request and a simple
openURLConnection to, what else, a url.

Ryan

Re: Server output as a result of the CustomInvoker and Client output after parameterization refactoring of Client, CustomerService, and Order

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

> In addition, I found out that the browser is also receiving the 400 status
> code.
> At minimum, due to expecting text/xml, when it gets a blank screen, it says
> that it cannot parse it.

I don't think it is actually getting an empty 400, the fact CXF
transport sets Content-Header should not cause that XML parsing error,
you could use a tcpmon utility to confirm it (use say 8081 in your
request URI and configure tcpmon to redirect from 8081 to 8080)

Cheers, Sergey

>
> Here is the response to the browser, which was captured with a Firefox
> plugin called Http Response Browser 0.3:
>
> http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/response.toBrowser.400_status
>
> https://addons.mozilla.org/en-US/firefox/addon/http-response-browser/
>
> and here is what the response looks like when the browser prints a message
> in response to it:
>
> http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/400_header_url_response_to_browser.png
>
> Have a great weekend also.
>
> Ryan
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Re: Server output as a result of the CustomInvoker and Client output after parameterization refactoring of Client, CustomerService, and Order

Posted by Ryan Zoerner <ry...@gmail.com>.
Hi,

Here is a link to Server.java, CustomerResourceProvider.java,
CustomInvoker.java, and, CustomExceptionMapper.java:

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/Server.java

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/CustomResourceProvider.java

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/CustomInvoker.java

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/CustomExceptionMapper.java

In addition, I found out that the browser is also receiving the 400 status
code.
At minimum, due to expecting text/xml, when it gets a blank screen, it says
that it cannot parse it.

Here is the response to the browser, which was captured with a Firefox
plugin called Http Response Browser 0.3:

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/response.toBrowser.400_status

https://addons.mozilla.org/en-US/firefox/addon/http-response-browser/

and here is what the response looks like when the browser prints a message
in response to it:

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/400_header_url_response_to_browser.png

Have a great weekend also.

Ryan

Re: Server output as a result of the CustomInvoker and Client output after parameterization refactoring of Client, CustomerService, and Order

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Fri, May 13, 2011 at 1:37 PM, Ryan Zoerner <ry...@gmail.com> wrote:
> Here are the links to the CustomerService.java and Client.java files that I
> have in my development environment.
>
> Also, here are the output files from the client and the server.
>
> You can see from the header that the 400 status code happens fine.
>
> I think that the xml error might be as a result of cxf catching the
> exception, but I think that Jetty may be throwing up the xml parsing error,
> on its own, for some reason.
>
> http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/Client.java
>
> http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/CustomerService.java
>
> http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/output.client
>
> http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/output.server
>
> http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/output.client.400_status
>

Are you using CustomResourceProvider for CustomerService as well ?
That is OK, I'm presuming CustomerService is singleton...

It all looks good, I guess we will be ready to move to the EJB
integration on Mon/Tue.

have a good weekend
Sergey

>
> Ryan
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Re: Server output as a result of the CustomInvoker and Client output after parameterization refactoring of Client, CustomerService, and Order

Posted by Ryan Zoerner <ry...@gmail.com>.
Here are the links to the CustomerService.java and Client.java files that I
have in my development environment.

Also, here are the output files from the client and the server.

You can see from the header that the 400 status code happens fine.

I think that the xml error might be as a result of cxf catching the
exception, but I think that Jetty may be throwing up the xml parsing error,
on its own, for some reason.

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/Client.java

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/CustomerService.java

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/output.client

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/output.server

http://pages.cs.wisc.edu/~zoerner/downloads/dev/samples/jaxrs_basic_http_demo/output.client.400_status


Ryan

Re: Server output as a result of the CustomInvoker and Client output after parameterization refactoring of Client, CustomerService, and Order

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Ryan

Brilliant, you are moving fast now.
So, as agreed, customize the demo a bit more (add two jaxrs endpoints,
use subresource locator for the 2nd endpoint which uses Customer as
the root resource), make sure you can use request URIs from Java and
browser clients, including the case where custom ExceptionMappers
customize the response, and register your own implementation of
per-request resource provider for the 2nd endpoint. I think you'll
feel much more confident about the whole project once you are done
with this task. And yes, post me a Maven based project :-), we'll need
to use Maven later on anyway

Cheers, Sergey

On Thu, May 12, 2011 at 9:31 AM, Ryan Zoerner <ry...@gmail.com> wrote:
> This is follow-up info to the things that I discussed here:
> http://cxf.547215.n5.nabble.com/Basic-Http-Demo-and-the-refactoring-that-I-did-in-the-course-of-figuring-out-how-it-worked-td4389413.html
>
> and here:
> http://cxf.547215.n5.nabble.com/demo-jaxrs-server-CustomInvoker-td4389484.html
>
> ------------------------------------------------
> Custom Invoker:
> ------------------------------------------------
> Here is the terminal output from the Server which has registered a
> CustomInvoker.
>
> The registration was done in Server.java
>
> here:
>
> Server.java
> --------------------------------------------------------------------------------------------------------
> ...
> sf.setInvoker(new CustomInvoker());
> ...
> --------------------------------------------------------------------------------------------------------
>
> and here is the new output:
>
> mvn -Pserver
> --------------------------------------------------------------------------------------------------------
>
> There are no tests to run.
>
> Results :
>
> Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
>
> [INFO]
> [INFO] >>> exec-maven-plugin:1.2:java (default) @ jax_rs_basic >>>
> [INFO]
> [INFO] <<< exec-maven-plugin:1.2:java (default) @ jax_rs_basic <<<
> [INFO]
> [INFO] --- exec-maven-plugin:1.2:java (default) @ jax_rs_basic ---
> product 323
> product 324
> product 325
> May 12, 2011 3:18:08 AM org.apache.cxf.endpoint.ServerImpl initDestination
> INFO: Setting the server's publish address to be http://localhost:9000/
> May 12, 2011 3:18:09 AM org.eclipse.jetty.util.log.Slf4jLog info
> INFO: jetty-7.3.1.v20110307
> May 12, 2011 3:18:09 AM org.eclipse.jetty.util.log.Slf4jLog info
> INFO: Started SelectChannelConnector@localhost:9000
> May 12, 2011 3:18:09 AM org.eclipse.jetty.util.log.Slf4jLog info
> INFO: started o.e.j.s.h.ContextHandler{,null}
> Server ready...
>
> ***
> The method about to be invoked
> by the CustomInvoker
> is named
> --->  getCustomerByID
> ***
>
> ----invoking getCustomer, Customer id is: 123
>
> ***
> The method about to be invoked
> by the CustomInvoker
> is named
> --->  getOrder
> ***
>
> ----invoking getOrder, Order id is: 223
> ----invoking getProduct with id: 323
>
> ***
> The method about to be invoked
> by the CustomInvoker
> is named
> --->  getOrder
> ***
>
> ----invoking getOrder, Order id is: 224
> ----invoking getProduct with id: 324
>
> ***
> The method about to be invoked
> by the CustomInvoker
> is named
> --->  getOrder
> ***
>
> ----invoking getOrder, Order id is: 225
> ----invoking getProduct with id: 325
>
> ***
> The method about to be invoked
> by the CustomInvoker
> is named
> --->  updateCustomer
> ***
>
> ----invoking updateCustomer, Customer name is: Mary
>
> ***
> The method about to be invoked
> by the CustomInvoker
> is named
> --->  addCustomer
> ***
>
> ----invoking addCustomer, Customer name is: Jack
> Server exiting
> S:\cxf\distribution\src\main\release\samples\jax_rs\basic>
> --------------------------------------------------------------------------------------------------------
>
>
> I thought that the firewall and administrative settings on this Windows
> operating system would prevent me from printing this, but it turns out
> that I was incorrect about that.
>
>
>
> ------------------------------------------------
> Client output with refactoring:
> ------------------------------------------------
> Also, so that you can see the results of the refactoring that I mentioned,
> I have also included the client output here:
>
> mvn -Pclient
> --------------------------------------------------------------------------------------------------------
>
> [INFO] Scanning for projects...
> ...
> [INFO] --- exec-maven-plugin:1.2:java (default) @ jax_rs_basic ---
> Sent HTTP GET request to query customer info
> http://localhost:9000/customerservice/customers/123
> <?xml version="1.0" encoding="UTF-8"
> standalone="yes"?><Customer><id>123</id><na
> me>John</name></Customer>
>
>
>
>
> Sent HTTP GET request to query sub resource product info
> http://localhost:9000/customerservice/orders/223/products/323
> <?xml version="1.0" encoding="UTF-8"
> standalone="yes"?><Product><description>pro
> duct 323</description><id>323</id></Product>
>
>
> Sent HTTP GET request to query sub resource product info
> http://localhost:9000/customerservice/orders/224/products/324
> <?xml version="1.0" encoding="UTF-8"
> standalone="yes"?><Product><description>pro
> duct 324</description><id>324</id></Product>
>
>
> Sent HTTP GET request to query sub resource product info
> http://localhost:9000/customerservice/orders/225/products/325
> <?xml version="1.0" encoding="UTF-8"
> standalone="yes"?><Product><description>pro
> duct 325</description><id>325</id></Product>
>
>
>
>
> Sent HTTP PUT request to update customer info
> Response status code: 200
> Response body:
>
>
>
> Sent HTTP POST request to add customer
> Response status code: 200
> Response body:
> <?xml version="1.0" encoding="UTF-8"
> standalone="yes"?><Customer><id>124</id><na
> me>Jack</name></Customer>
>
>
> S:\cxf\distribution\src\main\release\samples\jax_rs\basic>
> --------------------------------------------------------------------------------------------------------
>
>
> This was the output from the code that I showed, or at least approximately.
> I mention
> this because in my most recent iteration of changing the Client, I have been
> printing
> the url contents and url headers explicitly. This helped me figure out more
> about
> what seems to be the equivalence of an HTTP GET Request and a simple
> openURLConnection to, what else, a url.
>
> Ryan
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com