cancel
Showing results for 
Search instead for 
Did you mean: 

Jason to XML using REST Adapter

venkatagiri_gongadi
Participant
0 Kudos

Hi,

I am working on Jason to XML conversion using Sender REST adapter ,I am facing some issues,please help on them,

I have provided the URL to third party and it is giving below error,

URL pattern "/{service_part}/{resource_part}/{id_part}" matches request URL "/contract"Invalid number of elements in URL "/contract". 3 expected, 1 received.

URL is  http:<myHost>:<myPort>/RESTAdapter/Customer

Cheers,

Giri

Accepted Solutions (0)

Answers (1)

Answers (1)

venkatagiri_gongadi
Participant
0 Kudos

Hi,

Can you please tell me how to test it in case of Jason to XML conversion?

If we run the URL ,what would be the result?

Cheers,

Giri

vadimklimov
Active Contributor
0 Kudos

Hi Giri,

According to URL pattern mentioned by you, REST adapter would expect 3 parameters to be passed in URL, so you should either adjust URL pattern configuration in REST sender communication channel, or adopt URL that you call.

If you didn't configure any endpoint in communication channel, then the called URL shall have following format: http(s):<host>:<http(s) port>/RESTAdapter/<value for variable service_part>/<value for variable resource_part>/<value for variable id_part> whereas you most likely call http(s):<host>:<http(s) port>/RESTAdapter/contract.

If you don't pass any data in a body of a REST call, then choosing between JSON or XML doesn't really matter, since this configuration applies to format that is used for REST body parsing and processing and has no effect on constructed and passed URLs. So if you only get a resource and pass all data in URL as parameters, then you need to get use of dynamic attributes binding (in REST sender communication channel) and retrieval of their values in a mapping by means of adapter specific message attributes (for example, using user defined function / function library if your mapping is graphical, or embed retrieval of adapter specific message attribute value in you Java code if you mapping is Java mapping). This is well described in a blog written by .

If you pass some data in a body, then JSON may be applicable for such a use case. JSON to XML conversion is done by REST adapter automatically. Some customization options for this conversion and an example are available in a blog (also written by ).

Regards,

Vadim

venkatagiri_gongadi
Participant
0 Kudos

Hi Vadim,

Thanks for this info.

I have added a end point in sender communication channel and i will try to test with the URL ,adding endpoint and with data in the body.

What is the expected result if run the URL with endpoint or without endpoint?

How can we sure that endpoint url is correct?

Cheers,

Giri

vadimklimov
Active Contributor
0 Kudos

Custom endpoint is optional - if you don't use it in sender communication channel, REST adapter will use a fixed endpoint (preceded with only /RESTAdapter/ and not /RESTAdapter/<you custom endpoint name>). II'd rather recommend you focusing on variable part of URL and parameters that you pass there in order to solve a problem with mismatch between expected parameters and really provided.

Regards,

Vadim