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 <[email protected]> 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 <[email protected]>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
>>
>
>