You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kiren Pillay <ki...@gmail.com> on 2013/11/01 08:31:21 UTC
POSTing XML to REST Webservice
HI All,
I need to post an XML entity to a restful web-service, however my service
isn't picking up the request for some reason, I'm getting a null value for
my request.
Can someone please guide me in the right direction. I'm using the JAXB
Provider.
Here's my service:
@POST
@Produces({ MediaType.APPLICATION_XML })
public Response execute(@QueryParam("") MmsBillingRequest request)
throws Exception {
System.err.println("REQUEST RECEIVED");
Response response = new Response();
try {
request.getOriginatorInterface();
My Test Client:
String xmlRequest = "<MmsBillingRequest> "
+ " <originatorMsisdn>27823339811
</originatorMsisdn>"
+ " <originatorInterface />" + " <payloadSize/>"
+ " <messageClass/>" + " <readRepRequested/>"
+ " <timeStamp/>" + " <recipients/>"
+ "</MmsBillingRequest>";
// ****************
WebClient wc = WebClient.create(
"
http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling",
"test", "test", null);
wc.type("application/xml").accept("application/xml");
long l1 = System.currentTimeMillis();
// Response response = wc.get(Response.class);
Response response = wc.post(xmlRequest);
System.out.println(response.getEntity());
Regards
Kiren
Re: POSTing XML to REST Webservice
Posted by Kiren Pillay <ki...@gmail.com>.
Okay, thanks Sergey!
On Sun, Nov 17, 2013 at 11:23 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
> Hi Kiren
>
> On 17/11/13 20:44, Kiren Pillay wrote:
>
>> Hi Sergey,
>>
>> I think I may have managed to fix the issue, it was coming from my request
>> packet. For some reason, JAXB doesn't find the following two elements the
>> same.
>>
>> <mmsBillingRequest xmlns="http://www.mmsLogDetails.products.pams.co.za">
>> <originatorMsisdn>27829801407</originatorMsisdn>
>>
>> versus
>>
>> <ns2:mmsBillingRequest xmlns:ns2="
>> http://www.mmsLogDetails.products.pams.co.za">
>> <originatorMsisdn>27829801407</originatorMsisdn>
>>
>>
>> To me, these two xml snippets are equivalent, not sure why they don't work
>> the same.
>>
>>
> Most like your schema or JAXB assumes that in the 2nd option,
> <originatorMsisdn> is unqualified (it is qualified in the 1st one), you can
> control it at the package level with XmlSchema.
>
> Cheers, Sergey
>
>
> So I've reverted to the code you expected to work:
>> @POST
>> @Consumes({ MediaType.APPLICATION_XML })
>> @Produces({ MediaType.APPLICATION_XML })
>> @Path("mmsBilling")
>> public Response execute(MmsBillingRequest request) throws Exception {
>>
>>
>> Regards
>> Kiren
>>
>>
>>
>> On Sun, Nov 10, 2013 at 11:54 PM, Sergey Beryozkin <sberyozkin@gmail.com
>> >wrote:
>>
>> Hi Kiren
>>> Can you please open a JIRA and attach your project there ?
>>>
>>> Thanks, Sergey
>>>
>>> On 10/11/13 20:58, Kiren Pillay wrote:
>>>
>>> Hi Sergey,
>>>>
>>>> Where can I upload the test project?
>>>>
>>>> Regards
>>>> Kiren
>>>>
>>>>
>>>> On Sun, Nov 3, 2013 at 7:04 PM, Sergey Beryozkin <sberyozkin@gmail.com
>>>>
>>>>> wrote:
>>>>>
>>>>
>>>> Hi
>>>>
>>>>>
>>>>> This is very strange. I think something is interfering into the
>>>>> process,
>>>>> can you please create a basic test project reproducing the issue, very
>>>>> odd
>>>>> indeed
>>>>>
>>>>> Thanks, Sergey
>>>>>
>>>>> On 02/11/13 15:23, Kiren Pillay wrote:
>>>>>
>>>>> Thanks. I removed the QueryPAram as below,
>>>>>
>>>>>>
>>>>>> @POST
>>>>>> @Consumes({ MediaType.APPLICATION_XML })
>>>>>> @Produces({ MediaType.APPLICATION_XML })
>>>>>> @Path("mmsBilling")
>>>>>> public Response execute(MmsBillingRequest request) throws
>>>>>> Exception {
>>>>>>
>>>>>>
>>>>>> Now I get a strange error:
>>>>>>
>>>>>> Caused by: javax.xml.bind.UnmarshalException: unexpected element
>>>>>> (uri:"",
>>>>>> local:"MmsBillingRequest"). Expected elements are <{
>>>>>> http://www.messaging.pams.xxx/response}Response>.
>>>>>>
>>>>>> Which is odd because the only part of my method signature with the
>>>>>> Response
>>>>>> type is the return, so not sure why the unMarshaller is expecting the
>>>>>> Response Type.
>>>>>>
>>>>>> Looking at my WADL for this operation:<resources base="
>>>>>> http://localhost:8080/RESTWEB/rest/">
>>>>>> <resource path="/function">
>>>>>> <resource path="/mmsBilling">
>>>>>> <method name="POST">
>>>>>> <request>
>>>>>> <representation mediaType="application/xml" />
>>>>>> </request>
>>>>>> <response>
>>>>>> <representation mediaType="application/xml"
>>>>>> element="prefix1:Response" />
>>>>>> </response>
>>>>>> </method>
>>>>>> </resource>
>>>>>> </resource>
>>>>>>
>>>>>> Is there maybe a way to define the type of the request/response in an
>>>>>> annotation? I'm guessing that may help?
>>>>>>
>>>>>> My request:
>>>>>> <MmsBillingRequest>
>>>>>> <originatorMsisdn>27831231231
>>>>>> </originatorMsisdn>
>>>>>> </MmsBillingRequest>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 1, 2013 at 1:08 PM, Sergey Beryozkin <
>>>>>> sberyozkin@gmail.com
>>>>>>
>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>> Hi
>>>>>>
>>>>>>
>>>>>>> You have a QueryParam attached to a parameter which is expected to
>>>>>>> represent a message body, so no attempt to read the stream is
>>>>>>> attempted
>>>>>>>
>>>>>>> Thanks, Sergey
>>>>>>>
>>>>>>> On 01/11/13 07:31, Kiren Pillay wrote:
>>>>>>>
>>>>>>> HI All,
>>>>>>>
>>>>>>>
>>>>>>>> I need to post an XML entity to a restful web-service, however my
>>>>>>>> service
>>>>>>>> isn't picking up the request for some reason, I'm getting a null
>>>>>>>> value
>>>>>>>> for
>>>>>>>> my request.
>>>>>>>>
>>>>>>>> Can someone please guide me in the right direction. I'm using the
>>>>>>>> JAXB
>>>>>>>> Provider.
>>>>>>>>
>>>>>>>> Here's my service:
>>>>>>>>
>>>>>>>> @POST
>>>>>>>> @Produces({ MediaType.APPLICATION_XML })
>>>>>>>> public Response execute(@QueryParam("") MmsBillingRequest
>>>>>>>> request)
>>>>>>>> throws Exception {
>>>>>>>> System.err.println("REQUEST RECEIVED");
>>>>>>>> Response response = new Response();
>>>>>>>> try {
>>>>>>>> request.getOriginatorInterface();
>>>>>>>>
>>>>>>>>
>>>>>>>> My Test Client:
>>>>>>>>
>>>>>>>> String xmlRequest = "<MmsBillingRequest> "
>>>>>>>> + " <originatorMsisdn>27823339811
>>>>>>>> </originatorMsisdn>"
>>>>>>>> + " <originatorInterface />" + "
>>>>>>>> <payloadSize/>"
>>>>>>>> + " <messageClass/>" + "
>>>>>>>> <readRepRequested/>"
>>>>>>>> + " <timeStamp/>" + " <recipients/>"
>>>>>>>> + "</MmsBillingRequest>";
>>>>>>>>
>>>>>>>> // ****************
>>>>>>>>
>>>>>>>> WebClient wc = WebClient.create(
>>>>>>>>
>>>>>>>> "
>>>>>>>> http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling
>>>>>>>> ",
>>>>>>>> "test", "test", null);
>>>>>>>>
>>>>>>>> wc.type("application/xml").
>>>>>>>> accept("application/xml");
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> long l1 = System.currentTimeMillis();
>>>>>>>> // Response response =
>>>>>>>> wc.get(Response.class);
>>>>>>>> Response response = wc.post(xmlRequest);
>>>>>>>> System.out.println(response.getEntity());
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Kiren
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>> Sergey Beryozkin
>>>>>>>
>>>>>>> Talend Community Coders
>>>>>>> http://coders.talend.com/
>>>>>>>
>>>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>> Sergey Beryozkin
>>>>>
>>>>> Talend Community Coders
>>>>> http://coders.talend.com/
>>>>>
>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>
>>>>>
>>>>>
>>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>> Blog: http://sberyozkin.blogspot.com
>>>
>>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
Re: POSTing XML to REST Webservice
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Kiren
On 17/11/13 20:44, Kiren Pillay wrote:
> Hi Sergey,
>
> I think I may have managed to fix the issue, it was coming from my request
> packet. For some reason, JAXB doesn't find the following two elements the
> same.
>
> <mmsBillingRequest xmlns="http://www.mmsLogDetails.products.pams.co.za">
> <originatorMsisdn>27829801407</originatorMsisdn>
>
> versus
>
> <ns2:mmsBillingRequest xmlns:ns2="
> http://www.mmsLogDetails.products.pams.co.za">
> <originatorMsisdn>27829801407</originatorMsisdn>
>
>
> To me, these two xml snippets are equivalent, not sure why they don't work
> the same.
>
Most like your schema or JAXB assumes that in the 2nd option,
<originatorMsisdn> is unqualified (it is qualified in the 1st one), you
can control it at the package level with XmlSchema.
Cheers, Sergey
> So I've reverted to the code you expected to work:
> @POST
> @Consumes({ MediaType.APPLICATION_XML })
> @Produces({ MediaType.APPLICATION_XML })
> @Path("mmsBilling")
> public Response execute(MmsBillingRequest request) throws Exception {
>
>
> Regards
> Kiren
>
>
>
> On Sun, Nov 10, 2013 at 11:54 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
>
>> Hi Kiren
>> Can you please open a JIRA and attach your project there ?
>>
>> Thanks, Sergey
>>
>> On 10/11/13 20:58, Kiren Pillay wrote:
>>
>>> Hi Sergey,
>>>
>>> Where can I upload the test project?
>>>
>>> Regards
>>> Kiren
>>>
>>>
>>> On Sun, Nov 3, 2013 at 7:04 PM, Sergey Beryozkin <sberyozkin@gmail.com
>>>> wrote:
>>>
>>> Hi
>>>>
>>>> This is very strange. I think something is interfering into the process,
>>>> can you please create a basic test project reproducing the issue, very
>>>> odd
>>>> indeed
>>>>
>>>> Thanks, Sergey
>>>>
>>>> On 02/11/13 15:23, Kiren Pillay wrote:
>>>>
>>>> Thanks. I removed the QueryPAram as below,
>>>>>
>>>>> @POST
>>>>> @Consumes({ MediaType.APPLICATION_XML })
>>>>> @Produces({ MediaType.APPLICATION_XML })
>>>>> @Path("mmsBilling")
>>>>> public Response execute(MmsBillingRequest request) throws
>>>>> Exception {
>>>>>
>>>>>
>>>>> Now I get a strange error:
>>>>>
>>>>> Caused by: javax.xml.bind.UnmarshalException: unexpected element
>>>>> (uri:"",
>>>>> local:"MmsBillingRequest"). Expected elements are <{
>>>>> http://www.messaging.pams.xxx/response}Response>.
>>>>>
>>>>> Which is odd because the only part of my method signature with the
>>>>> Response
>>>>> type is the return, so not sure why the unMarshaller is expecting the
>>>>> Response Type.
>>>>>
>>>>> Looking at my WADL for this operation:<resources base="
>>>>> http://localhost:8080/RESTWEB/rest/">
>>>>> <resource path="/function">
>>>>> <resource path="/mmsBilling">
>>>>> <method name="POST">
>>>>> <request>
>>>>> <representation mediaType="application/xml" />
>>>>> </request>
>>>>> <response>
>>>>> <representation mediaType="application/xml"
>>>>> element="prefix1:Response" />
>>>>> </response>
>>>>> </method>
>>>>> </resource>
>>>>> </resource>
>>>>>
>>>>> Is there maybe a way to define the type of the request/response in an
>>>>> annotation? I'm guessing that may help?
>>>>>
>>>>> My request:
>>>>> <MmsBillingRequest>
>>>>> <originatorMsisdn>27831231231
>>>>> </originatorMsisdn>
>>>>> </MmsBillingRequest>
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Nov 1, 2013 at 1:08 PM, Sergey Beryozkin <sberyozkin@gmail.com
>>>>>
>>>>>> wrote:
>>>>>>
>>>>>
>>>>> Hi
>>>>>
>>>>>>
>>>>>> You have a QueryParam attached to a parameter which is expected to
>>>>>> represent a message body, so no attempt to read the stream is attempted
>>>>>>
>>>>>> Thanks, Sergey
>>>>>>
>>>>>> On 01/11/13 07:31, Kiren Pillay wrote:
>>>>>>
>>>>>> HI All,
>>>>>>
>>>>>>>
>>>>>>> I need to post an XML entity to a restful web-service, however my
>>>>>>> service
>>>>>>> isn't picking up the request for some reason, I'm getting a null value
>>>>>>> for
>>>>>>> my request.
>>>>>>>
>>>>>>> Can someone please guide me in the right direction. I'm using the
>>>>>>> JAXB
>>>>>>> Provider.
>>>>>>>
>>>>>>> Here's my service:
>>>>>>>
>>>>>>> @POST
>>>>>>> @Produces({ MediaType.APPLICATION_XML })
>>>>>>> public Response execute(@QueryParam("") MmsBillingRequest
>>>>>>> request)
>>>>>>> throws Exception {
>>>>>>> System.err.println("REQUEST RECEIVED");
>>>>>>> Response response = new Response();
>>>>>>> try {
>>>>>>> request.getOriginatorInterface();
>>>>>>>
>>>>>>>
>>>>>>> My Test Client:
>>>>>>>
>>>>>>> String xmlRequest = "<MmsBillingRequest> "
>>>>>>> + " <originatorMsisdn>27823339811
>>>>>>> </originatorMsisdn>"
>>>>>>> + " <originatorInterface />" + "
>>>>>>> <payloadSize/>"
>>>>>>> + " <messageClass/>" + "
>>>>>>> <readRepRequested/>"
>>>>>>> + " <timeStamp/>" + " <recipients/>"
>>>>>>> + "</MmsBillingRequest>";
>>>>>>>
>>>>>>> // ****************
>>>>>>>
>>>>>>> WebClient wc = WebClient.create(
>>>>>>>
>>>>>>> "
>>>>>>> http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling",
>>>>>>> "test", "test", null);
>>>>>>>
>>>>>>> wc.type("application/xml").
>>>>>>> accept("application/xml");
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> long l1 = System.currentTimeMillis();
>>>>>>> // Response response = wc.get(Response.class);
>>>>>>> Response response = wc.post(xmlRequest);
>>>>>>> System.out.println(response.getEntity());
>>>>>>>
>>>>>>>
>>>>>>> Regards
>>>>>>> Kiren
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>> Sergey Beryozkin
>>>>>>
>>>>>> Talend Community Coders
>>>>>> http://coders.talend.com/
>>>>>>
>>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> Talend Community Coders
>>>> http://coders.talend.com/
>>>>
>>>> Blog: http://sberyozkin.blogspot.com
>>>>
>>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: POSTing XML to REST Webservice
Posted by Kiren Pillay <ki...@gmail.com>.
Hi Sergey,
I think I may have managed to fix the issue, it was coming from my request
packet. For some reason, JAXB doesn't find the following two elements the
same.
<mmsBillingRequest xmlns="http://www.mmsLogDetails.products.pams.co.za">
<originatorMsisdn>27829801407</originatorMsisdn>
versus
<ns2:mmsBillingRequest xmlns:ns2="
http://www.mmsLogDetails.products.pams.co.za">
<originatorMsisdn>27829801407</originatorMsisdn>
To me, these two xml snippets are equivalent, not sure why they don't work
the same.
So I've reverted to the code you expected to work:
@POST
@Consumes({ MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_XML })
@Path("mmsBilling")
public Response execute(MmsBillingRequest request) throws Exception {
Regards
Kiren
On Sun, Nov 10, 2013 at 11:54 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
> Hi Kiren
> Can you please open a JIRA and attach your project there ?
>
> Thanks, Sergey
>
> On 10/11/13 20:58, Kiren Pillay wrote:
>
>> Hi Sergey,
>>
>> Where can I upload the test project?
>>
>> Regards
>> Kiren
>>
>>
>> On Sun, Nov 3, 2013 at 7:04 PM, Sergey Beryozkin <sberyozkin@gmail.com
>> >wrote:
>>
>> Hi
>>>
>>> This is very strange. I think something is interfering into the process,
>>> can you please create a basic test project reproducing the issue, very
>>> odd
>>> indeed
>>>
>>> Thanks, Sergey
>>>
>>> On 02/11/13 15:23, Kiren Pillay wrote:
>>>
>>> Thanks. I removed the QueryPAram as below,
>>>>
>>>> @POST
>>>> @Consumes({ MediaType.APPLICATION_XML })
>>>> @Produces({ MediaType.APPLICATION_XML })
>>>> @Path("mmsBilling")
>>>> public Response execute(MmsBillingRequest request) throws
>>>> Exception {
>>>>
>>>>
>>>> Now I get a strange error:
>>>>
>>>> Caused by: javax.xml.bind.UnmarshalException: unexpected element
>>>> (uri:"",
>>>> local:"MmsBillingRequest"). Expected elements are <{
>>>> http://www.messaging.pams.xxx/response}Response>.
>>>>
>>>> Which is odd because the only part of my method signature with the
>>>> Response
>>>> type is the return, so not sure why the unMarshaller is expecting the
>>>> Response Type.
>>>>
>>>> Looking at my WADL for this operation:<resources base="
>>>> http://localhost:8080/RESTWEB/rest/">
>>>> <resource path="/function">
>>>> <resource path="/mmsBilling">
>>>> <method name="POST">
>>>> <request>
>>>> <representation mediaType="application/xml" />
>>>> </request>
>>>> <response>
>>>> <representation mediaType="application/xml"
>>>> element="prefix1:Response" />
>>>> </response>
>>>> </method>
>>>> </resource>
>>>> </resource>
>>>>
>>>> Is there maybe a way to define the type of the request/response in an
>>>> annotation? I'm guessing that may help?
>>>>
>>>> My request:
>>>> <MmsBillingRequest>
>>>> <originatorMsisdn>27831231231
>>>> </originatorMsisdn>
>>>> </MmsBillingRequest>
>>>>
>>>>
>>>>
>>>> On Fri, Nov 1, 2013 at 1:08 PM, Sergey Beryozkin <sberyozkin@gmail.com
>>>>
>>>>> wrote:
>>>>>
>>>>
>>>> Hi
>>>>
>>>>>
>>>>> You have a QueryParam attached to a parameter which is expected to
>>>>> represent a message body, so no attempt to read the stream is attempted
>>>>>
>>>>> Thanks, Sergey
>>>>>
>>>>> On 01/11/13 07:31, Kiren Pillay wrote:
>>>>>
>>>>> HI All,
>>>>>
>>>>>>
>>>>>> I need to post an XML entity to a restful web-service, however my
>>>>>> service
>>>>>> isn't picking up the request for some reason, I'm getting a null value
>>>>>> for
>>>>>> my request.
>>>>>>
>>>>>> Can someone please guide me in the right direction. I'm using the
>>>>>> JAXB
>>>>>> Provider.
>>>>>>
>>>>>> Here's my service:
>>>>>>
>>>>>> @POST
>>>>>> @Produces({ MediaType.APPLICATION_XML })
>>>>>> public Response execute(@QueryParam("") MmsBillingRequest
>>>>>> request)
>>>>>> throws Exception {
>>>>>> System.err.println("REQUEST RECEIVED");
>>>>>> Response response = new Response();
>>>>>> try {
>>>>>> request.getOriginatorInterface();
>>>>>>
>>>>>>
>>>>>> My Test Client:
>>>>>>
>>>>>> String xmlRequest = "<MmsBillingRequest> "
>>>>>> + " <originatorMsisdn>27823339811
>>>>>> </originatorMsisdn>"
>>>>>> + " <originatorInterface />" + "
>>>>>> <payloadSize/>"
>>>>>> + " <messageClass/>" + "
>>>>>> <readRepRequested/>"
>>>>>> + " <timeStamp/>" + " <recipients/>"
>>>>>> + "</MmsBillingRequest>";
>>>>>>
>>>>>> // ****************
>>>>>>
>>>>>> WebClient wc = WebClient.create(
>>>>>>
>>>>>> "
>>>>>> http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling",
>>>>>> "test", "test", null);
>>>>>>
>>>>>> wc.type("application/xml").
>>>>>> accept("application/xml");
>>>>>>
>>>>>>
>>>>>>
>>>>>> long l1 = System.currentTimeMillis();
>>>>>> // Response response = wc.get(Response.class);
>>>>>> Response response = wc.post(xmlRequest);
>>>>>> System.out.println(response.getEntity());
>>>>>>
>>>>>>
>>>>>> Regards
>>>>>> Kiren
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>> Sergey Beryozkin
>>>>>
>>>>> Talend Community Coders
>>>>> http://coders.talend.com/
>>>>>
>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>
>>>>>
>>>>>
>>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>> Blog: http://sberyozkin.blogspot.com
>>>
>>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
Re: POSTing XML to REST Webservice
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Kiren
Can you please open a JIRA and attach your project there ?
Thanks, Sergey
On 10/11/13 20:58, Kiren Pillay wrote:
> Hi Sergey,
>
> Where can I upload the test project?
>
> Regards
> Kiren
>
>
> On Sun, Nov 3, 2013 at 7:04 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
>
>> Hi
>>
>> This is very strange. I think something is interfering into the process,
>> can you please create a basic test project reproducing the issue, very odd
>> indeed
>>
>> Thanks, Sergey
>>
>> On 02/11/13 15:23, Kiren Pillay wrote:
>>
>>> Thanks. I removed the QueryPAram as below,
>>>
>>> @POST
>>> @Consumes({ MediaType.APPLICATION_XML })
>>> @Produces({ MediaType.APPLICATION_XML })
>>> @Path("mmsBilling")
>>> public Response execute(MmsBillingRequest request) throws Exception {
>>>
>>>
>>> Now I get a strange error:
>>>
>>> Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"",
>>> local:"MmsBillingRequest"). Expected elements are <{
>>> http://www.messaging.pams.xxx/response}Response>.
>>>
>>> Which is odd because the only part of my method signature with the
>>> Response
>>> type is the return, so not sure why the unMarshaller is expecting the
>>> Response Type.
>>>
>>> Looking at my WADL for this operation:<resources base="
>>> http://localhost:8080/RESTWEB/rest/">
>>> <resource path="/function">
>>> <resource path="/mmsBilling">
>>> <method name="POST">
>>> <request>
>>> <representation mediaType="application/xml" />
>>> </request>
>>> <response>
>>> <representation mediaType="application/xml"
>>> element="prefix1:Response" />
>>> </response>
>>> </method>
>>> </resource>
>>> </resource>
>>>
>>> Is there maybe a way to define the type of the request/response in an
>>> annotation? I'm guessing that may help?
>>>
>>> My request:
>>> <MmsBillingRequest>
>>> <originatorMsisdn>27831231231
>>> </originatorMsisdn>
>>> </MmsBillingRequest>
>>>
>>>
>>>
>>> On Fri, Nov 1, 2013 at 1:08 PM, Sergey Beryozkin <sberyozkin@gmail.com
>>>> wrote:
>>>
>>> Hi
>>>>
>>>> You have a QueryParam attached to a parameter which is expected to
>>>> represent a message body, so no attempt to read the stream is attempted
>>>>
>>>> Thanks, Sergey
>>>>
>>>> On 01/11/13 07:31, Kiren Pillay wrote:
>>>>
>>>> HI All,
>>>>>
>>>>> I need to post an XML entity to a restful web-service, however my
>>>>> service
>>>>> isn't picking up the request for some reason, I'm getting a null value
>>>>> for
>>>>> my request.
>>>>>
>>>>> Can someone please guide me in the right direction. I'm using the JAXB
>>>>> Provider.
>>>>>
>>>>> Here's my service:
>>>>>
>>>>> @POST
>>>>> @Produces({ MediaType.APPLICATION_XML })
>>>>> public Response execute(@QueryParam("") MmsBillingRequest request)
>>>>> throws Exception {
>>>>> System.err.println("REQUEST RECEIVED");
>>>>> Response response = new Response();
>>>>> try {
>>>>> request.getOriginatorInterface();
>>>>>
>>>>>
>>>>> My Test Client:
>>>>>
>>>>> String xmlRequest = "<MmsBillingRequest> "
>>>>> + " <originatorMsisdn>27823339811
>>>>> </originatorMsisdn>"
>>>>> + " <originatorInterface />" + "
>>>>> <payloadSize/>"
>>>>> + " <messageClass/>" + "
>>>>> <readRepRequested/>"
>>>>> + " <timeStamp/>" + " <recipients/>"
>>>>> + "</MmsBillingRequest>";
>>>>>
>>>>> // ****************
>>>>>
>>>>> WebClient wc = WebClient.create(
>>>>>
>>>>> "
>>>>> http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling",
>>>>> "test", "test", null);
>>>>>
>>>>> wc.type("application/xml").accept("application/xml");
>>>>>
>>>>>
>>>>>
>>>>> long l1 = System.currentTimeMillis();
>>>>> // Response response = wc.get(Response.class);
>>>>> Response response = wc.post(xmlRequest);
>>>>> System.out.println(response.getEntity());
>>>>>
>>>>>
>>>>> Regards
>>>>> Kiren
>>>>>
>>>>>
>>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> Talend Community Coders
>>>> http://coders.talend.com/
>>>>
>>>> Blog: http://sberyozkin.blogspot.com
>>>>
>>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: POSTing XML to REST Webservice
Posted by Kiren Pillay <ki...@gmail.com>.
Hi Sergey,
Where can I upload the test project?
Regards
Kiren
On Sun, Nov 3, 2013 at 7:04 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
> Hi
>
> This is very strange. I think something is interfering into the process,
> can you please create a basic test project reproducing the issue, very odd
> indeed
>
> Thanks, Sergey
>
> On 02/11/13 15:23, Kiren Pillay wrote:
>
>> Thanks. I removed the QueryPAram as below,
>>
>> @POST
>> @Consumes({ MediaType.APPLICATION_XML })
>> @Produces({ MediaType.APPLICATION_XML })
>> @Path("mmsBilling")
>> public Response execute(MmsBillingRequest request) throws Exception {
>>
>>
>> Now I get a strange error:
>>
>> Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"",
>> local:"MmsBillingRequest"). Expected elements are <{
>> http://www.messaging.pams.xxx/response}Response>.
>>
>> Which is odd because the only part of my method signature with the
>> Response
>> type is the return, so not sure why the unMarshaller is expecting the
>> Response Type.
>>
>> Looking at my WADL for this operation:<resources base="
>> http://localhost:8080/RESTWEB/rest/">
>> <resource path="/function">
>> <resource path="/mmsBilling">
>> <method name="POST">
>> <request>
>> <representation mediaType="application/xml" />
>> </request>
>> <response>
>> <representation mediaType="application/xml"
>> element="prefix1:Response" />
>> </response>
>> </method>
>> </resource>
>> </resource>
>>
>> Is there maybe a way to define the type of the request/response in an
>> annotation? I'm guessing that may help?
>>
>> My request:
>> <MmsBillingRequest>
>> <originatorMsisdn>27831231231
>> </originatorMsisdn>
>> </MmsBillingRequest>
>>
>>
>>
>> On Fri, Nov 1, 2013 at 1:08 PM, Sergey Beryozkin <sberyozkin@gmail.com
>> >wrote:
>>
>> Hi
>>>
>>> You have a QueryParam attached to a parameter which is expected to
>>> represent a message body, so no attempt to read the stream is attempted
>>>
>>> Thanks, Sergey
>>>
>>> On 01/11/13 07:31, Kiren Pillay wrote:
>>>
>>> HI All,
>>>>
>>>> I need to post an XML entity to a restful web-service, however my
>>>> service
>>>> isn't picking up the request for some reason, I'm getting a null value
>>>> for
>>>> my request.
>>>>
>>>> Can someone please guide me in the right direction. I'm using the JAXB
>>>> Provider.
>>>>
>>>> Here's my service:
>>>>
>>>> @POST
>>>> @Produces({ MediaType.APPLICATION_XML })
>>>> public Response execute(@QueryParam("") MmsBillingRequest request)
>>>> throws Exception {
>>>> System.err.println("REQUEST RECEIVED");
>>>> Response response = new Response();
>>>> try {
>>>> request.getOriginatorInterface();
>>>>
>>>>
>>>> My Test Client:
>>>>
>>>> String xmlRequest = "<MmsBillingRequest> "
>>>> + " <originatorMsisdn>27823339811
>>>> </originatorMsisdn>"
>>>> + " <originatorInterface />" + "
>>>> <payloadSize/>"
>>>> + " <messageClass/>" + "
>>>> <readRepRequested/>"
>>>> + " <timeStamp/>" + " <recipients/>"
>>>> + "</MmsBillingRequest>";
>>>>
>>>> // ****************
>>>>
>>>> WebClient wc = WebClient.create(
>>>>
>>>> "
>>>> http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling",
>>>> "test", "test", null);
>>>>
>>>> wc.type("application/xml").accept("application/xml");
>>>>
>>>>
>>>>
>>>> long l1 = System.currentTimeMillis();
>>>> // Response response = wc.get(Response.class);
>>>> Response response = wc.post(xmlRequest);
>>>> System.out.println(response.getEntity());
>>>>
>>>>
>>>> Regards
>>>> Kiren
>>>>
>>>>
>>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>> Blog: http://sberyozkin.blogspot.com
>>>
>>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
Re: POSTing XML to REST Webservice
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
This is very strange. I think something is interfering into the process,
can you please create a basic test project reproducing the issue, very
odd indeed
Thanks, Sergey
On 02/11/13 15:23, Kiren Pillay wrote:
> Thanks. I removed the QueryPAram as below,
>
> @POST
> @Consumes({ MediaType.APPLICATION_XML })
> @Produces({ MediaType.APPLICATION_XML })
> @Path("mmsBilling")
> public Response execute(MmsBillingRequest request) throws Exception {
>
>
> Now I get a strange error:
>
> Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"",
> local:"MmsBillingRequest"). Expected elements are <{
> http://www.messaging.pams.xxx/response}Response>.
>
> Which is odd because the only part of my method signature with the Response
> type is the return, so not sure why the unMarshaller is expecting the
> Response Type.
>
> Looking at my WADL for this operation:<resources base="
> http://localhost:8080/RESTWEB/rest/">
> <resource path="/function">
> <resource path="/mmsBilling">
> <method name="POST">
> <request>
> <representation mediaType="application/xml" />
> </request>
> <response>
> <representation mediaType="application/xml"
> element="prefix1:Response" />
> </response>
> </method>
> </resource>
> </resource>
>
> Is there maybe a way to define the type of the request/response in an
> annotation? I'm guessing that may help?
>
> My request:
> <MmsBillingRequest>
> <originatorMsisdn>27831231231
> </originatorMsisdn>
> </MmsBillingRequest>
>
>
>
> On Fri, Nov 1, 2013 at 1:08 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
>
>> Hi
>>
>> You have a QueryParam attached to a parameter which is expected to
>> represent a message body, so no attempt to read the stream is attempted
>>
>> Thanks, Sergey
>>
>> On 01/11/13 07:31, Kiren Pillay wrote:
>>
>>> HI All,
>>>
>>> I need to post an XML entity to a restful web-service, however my service
>>> isn't picking up the request for some reason, I'm getting a null value for
>>> my request.
>>>
>>> Can someone please guide me in the right direction. I'm using the JAXB
>>> Provider.
>>>
>>> Here's my service:
>>>
>>> @POST
>>> @Produces({ MediaType.APPLICATION_XML })
>>> public Response execute(@QueryParam("") MmsBillingRequest request)
>>> throws Exception {
>>> System.err.println("REQUEST RECEIVED");
>>> Response response = new Response();
>>> try {
>>> request.getOriginatorInterface();
>>>
>>>
>>> My Test Client:
>>>
>>> String xmlRequest = "<MmsBillingRequest> "
>>> + " <originatorMsisdn>27823339811
>>> </originatorMsisdn>"
>>> + " <originatorInterface />" + " <payloadSize/>"
>>> + " <messageClass/>" + " <readRepRequested/>"
>>> + " <timeStamp/>" + " <recipients/>"
>>> + "</MmsBillingRequest>";
>>>
>>> // ****************
>>>
>>> WebClient wc = WebClient.create(
>>>
>>> "
>>> http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling",
>>> "test", "test", null);
>>>
>>> wc.type("application/xml").accept("application/xml");
>>>
>>>
>>>
>>> long l1 = System.currentTimeMillis();
>>> // Response response = wc.get(Response.class);
>>> Response response = wc.post(xmlRequest);
>>> System.out.println(response.getEntity());
>>>
>>>
>>> Regards
>>> Kiren
>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: POSTing XML to REST Webservice
Posted by Kiren Pillay <ki...@gmail.com>.
I used a different strategy to get this working:
@POST
@Consumes({ MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_XML })
@Path("mmsBilling")
public Response execute(XMLSource xml) throws Exception {
Map<String, String> nameSpaces=new HashedMap();
nameSpaces.put("ns2","http://www.mmsLogDetails.products.pams.co.za
");
MmsBillingRequest mms=xml.getNode("/", MmsBillingRequest.class);
String msisdn = mms.getOriginatorMsisdn();
On Sat, Nov 2, 2013 at 5:23 PM, Kiren Pillay <ki...@gmail.com> wrote:
> Thanks. I removed the QueryPAram as below,
>
> @POST
> @Consumes({ MediaType.APPLICATION_XML })
> @Produces({ MediaType.APPLICATION_XML })
> @Path("mmsBilling")
> public Response execute(MmsBillingRequest request) throws Exception {
>
>
> Now I get a strange error:
>
> Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"",
> local:"MmsBillingRequest"). Expected elements are <{
> http://www.messaging.pams.xxx/response}Response>.
>
> Which is odd because the only part of my method signature with the
> Response type is the return, so not sure why the unMarshaller is expecting
> the Response Type.
>
> Looking at my WADL for this operation:<resources base="
> http://localhost:8080/RESTWEB/rest/">
> <resource path="/function">
> <resource path="/mmsBilling">
> <method name="POST">
> <request>
> <representation mediaType="application/xml" />
> </request>
> <response>
> <representation mediaType="application/xml"
> element="prefix1:Response" />
> </response>
> </method>
> </resource>
> </resource>
>
> Is there maybe a way to define the type of the request/response in an
> annotation? I'm guessing that may help?
>
> My request:
> <MmsBillingRequest>
> <originatorMsisdn>27831231231
> </originatorMsisdn>
> </MmsBillingRequest>
>
>
>
> On Fri, Nov 1, 2013 at 1:08 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
>
>> Hi
>>
>> You have a QueryParam attached to a parameter which is expected to
>> represent a message body, so no attempt to read the stream is attempted
>>
>> Thanks, Sergey
>>
>> On 01/11/13 07:31, Kiren Pillay wrote:
>>
>>> HI All,
>>>
>>> I need to post an XML entity to a restful web-service, however my service
>>> isn't picking up the request for some reason, I'm getting a null value
>>> for
>>> my request.
>>>
>>> Can someone please guide me in the right direction. I'm using the JAXB
>>> Provider.
>>>
>>> Here's my service:
>>>
>>> @POST
>>> @Produces({ MediaType.APPLICATION_XML })
>>> public Response execute(@QueryParam("") MmsBillingRequest request)
>>> throws Exception {
>>> System.err.println("REQUEST RECEIVED");
>>> Response response = new Response();
>>> try {
>>> request.getOriginatorInterface();
>>>
>>>
>>> My Test Client:
>>>
>>> String xmlRequest = "<MmsBillingRequest> "
>>> + " <originatorMsisdn>27823339811
>>> </originatorMsisdn>"
>>> + " <originatorInterface />" + "
>>> <payloadSize/>"
>>> + " <messageClass/>" + " <readRepRequested/>"
>>> + " <timeStamp/>" + " <recipients/>"
>>> + "</MmsBillingRequest>";
>>>
>>> // ****************
>>>
>>> WebClient wc = WebClient.create(
>>>
>>> "
>>> http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling",
>>> "test", "test", null);
>>>
>>> wc.type("application/xml").accept("application/xml");
>>>
>>>
>>>
>>> long l1 = System.currentTimeMillis();
>>> // Response response = wc.get(Response.class);
>>> Response response = wc.post(xmlRequest);
>>> System.out.println(response.getEntity());
>>>
>>>
>>> Regards
>>> Kiren
>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com
>>
>
>
Re: POSTing XML to REST Webservice
Posted by Kiren Pillay <ki...@gmail.com>.
Thanks. I removed the QueryPAram as below,
@POST
@Consumes({ MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_XML })
@Path("mmsBilling")
public Response execute(MmsBillingRequest request) throws Exception {
Now I get a strange error:
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"",
local:"MmsBillingRequest"). Expected elements are <{
http://www.messaging.pams.xxx/response}Response>.
Which is odd because the only part of my method signature with the Response
type is the return, so not sure why the unMarshaller is expecting the
Response Type.
Looking at my WADL for this operation:<resources base="
http://localhost:8080/RESTWEB/rest/">
<resource path="/function">
<resource path="/mmsBilling">
<method name="POST">
<request>
<representation mediaType="application/xml" />
</request>
<response>
<representation mediaType="application/xml"
element="prefix1:Response" />
</response>
</method>
</resource>
</resource>
Is there maybe a way to define the type of the request/response in an
annotation? I'm guessing that may help?
My request:
<MmsBillingRequest>
<originatorMsisdn>27831231231
</originatorMsisdn>
</MmsBillingRequest>
On Fri, Nov 1, 2013 at 1:08 PM, Sergey Beryozkin <sb...@gmail.com>wrote:
> Hi
>
> You have a QueryParam attached to a parameter which is expected to
> represent a message body, so no attempt to read the stream is attempted
>
> Thanks, Sergey
>
> On 01/11/13 07:31, Kiren Pillay wrote:
>
>> HI All,
>>
>> I need to post an XML entity to a restful web-service, however my service
>> isn't picking up the request for some reason, I'm getting a null value for
>> my request.
>>
>> Can someone please guide me in the right direction. I'm using the JAXB
>> Provider.
>>
>> Here's my service:
>>
>> @POST
>> @Produces({ MediaType.APPLICATION_XML })
>> public Response execute(@QueryParam("") MmsBillingRequest request)
>> throws Exception {
>> System.err.println("REQUEST RECEIVED");
>> Response response = new Response();
>> try {
>> request.getOriginatorInterface();
>>
>>
>> My Test Client:
>>
>> String xmlRequest = "<MmsBillingRequest> "
>> + " <originatorMsisdn>27823339811
>> </originatorMsisdn>"
>> + " <originatorInterface />" + " <payloadSize/>"
>> + " <messageClass/>" + " <readRepRequested/>"
>> + " <timeStamp/>" + " <recipients/>"
>> + "</MmsBillingRequest>";
>>
>> // ****************
>>
>> WebClient wc = WebClient.create(
>>
>> "
>> http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling",
>> "test", "test", null);
>>
>> wc.type("application/xml").accept("application/xml");
>>
>>
>>
>> long l1 = System.currentTimeMillis();
>> // Response response = wc.get(Response.class);
>> Response response = wc.post(xmlRequest);
>> System.out.println(response.getEntity());
>>
>>
>> Regards
>> Kiren
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
Re: POSTing XML to REST Webservice
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
You have a QueryParam attached to a parameter which is expected to
represent a message body, so no attempt to read the stream is attempted
Thanks, Sergey
On 01/11/13 07:31, Kiren Pillay wrote:
> HI All,
>
> I need to post an XML entity to a restful web-service, however my service
> isn't picking up the request for some reason, I'm getting a null value for
> my request.
>
> Can someone please guide me in the right direction. I'm using the JAXB
> Provider.
>
> Here's my service:
>
> @POST
> @Produces({ MediaType.APPLICATION_XML })
> public Response execute(@QueryParam("") MmsBillingRequest request)
> throws Exception {
> System.err.println("REQUEST RECEIVED");
> Response response = new Response();
> try {
> request.getOriginatorInterface();
>
>
> My Test Client:
>
> String xmlRequest = "<MmsBillingRequest> "
> + " <originatorMsisdn>27823339811
> </originatorMsisdn>"
> + " <originatorInterface />" + " <payloadSize/>"
> + " <messageClass/>" + " <readRepRequested/>"
> + " <timeStamp/>" + " <recipients/>"
> + "</MmsBillingRequest>";
>
> // ****************
>
> WebClient wc = WebClient.create(
>
> "
> http://localhost:9090/deploy-mms-billing/rest//function/mmsBilling",
> "test", "test", null);
>
> wc.type("application/xml").accept("application/xml");
>
>
>
> long l1 = System.currentTimeMillis();
> // Response response = wc.get(Response.class);
> Response response = wc.post(xmlRequest);
> System.out.println(response.getEntity());
>
>
> Regards
> Kiren
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com