Tuesday, December 7, 2010

JDeveloper and HttpClient to test a OSB "any XML" service

I want to code some Unit Tests for a Pure XML service.
SOAPUI doesn't seem to have any support for such services (maybe?).

So I will code something in Java. Actually I might do it in Groovy.

HttpClient is deployed 3 times (!!!) with SOASuite and JDev:




In reality httpclient 3 is a legacy code and one is encouraged to upgrade to 4

(download both core and httpclient jars)
here is the link with the dependencies.

Here a quick tutorial.

Bear in mind that even if you post a XML to a "Any XML" service, OSB will still wrap it into a soapenv:Body element....

so if you want to grab the payload you should get the XPath "./*" of variable $body...
using the XPath "." will return you an object of type Body.

Here is the harness:

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost request = new HttpPost("http://localhost:7001/CreateOrder/PS/CreateOrderPS");
HttpEntity httpEntity = new FileEntity(new File("C:\\JDeveloper\\mywork\\ACME_POC\\CreateOrderTest\\resources\\createorderpayload.xml"), "text/html");
HttpResponse response = httpclient.execute(request);

and of course the status should be 200
If it's 500 you might have a fault (e.g. validation error)

Here for my reference are the available sbresource queries:

* http://host:port/sbresource?WSDL/project/...wsdlname
* http://host:port/sbresource?POLICY/project/...policyname
* http://host:port/sbresource?MFL/project/...mflname
* http://host:port/sbresource?SCHEMA/project/...schemaname
* http://host:port/sbresource?PROXY/project/...proxyname


Damien said...


I think the url will need to include sbresource?PROXY directive in order to call the proxy service from a http client. Also doers the proxy service not require a WSDL service?

vernetto said...

Hello Damien,
if the Proxy Service is a "Any XML", no WSDL is associated to it...
if I am wrong please correct me.

actually the POST works without the "sbresource?PROXY" directive.... can you tell me more about this "sbresource?PROXY" thingie?


Damien said...

Hi Perluigi,

Apologies the sbresource?PROXY is used the url for accessing the WSDL of the proxy service as desribed here -http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/configuringandusingservices.html

This would be required if the proxy service was based on a WSDL and you needed to test via SOAPUI, XMLSPY etc

vernetto said...

actually I have tried:


and I get

java.io.IOException: This service is not associated to a wsdl

since it's a "Any XML" service....

Anyway it's interesting that you can retrieve those entities through a HTTP GET, nice one Damien!