|
Key
This line was removed.
This word was removed. This word was added.
This line was added.
|
Changes (3)
View Page HistoryIn this sample, we are going to expose a JBI service as REST service. The Service Unit configuration which will be used is :
todo {code:lang=xml}
<jbi:jbi version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-4.0"
xmlns:sample="http://petals.ow2.org/sample"
xmlns:soap="http://petals.ow2.org/components/soap/version-3.1">
<!-- Import a Service into PEtALS or Expose a PEtALS Service => use a BC. -->
<jbi:services binding-component="true">
<!-- Import a Service into PEtALS => provides a Service. -->
<jbi:consumes interface-name="sample:SampleProvider"
service-name="sample:SampleProviderService"
endpoint-name="SampleProvider">
<!-- CDK specific fields -->
<petalsCDK:mep>InOut</petalsCDK:mep>
<petalsCDK:operation>${input_operation}</petalsCDK:operation>
<!-- SOAP specific fields -->
<soap:address>RESTService</soap:address>
<soap:mode>REST</soap:mode>
<soap:rest-add-namespace-uri>
http://petals.ow2.org/sample
</soap:rest-add-namespace-uri>
<soap:rest-add-namespace-prefix>ns1</soap:rest-add-namespace-prefix>
<soap:rest-remove-prefix-on-response>*</soap:rest-remove-prefix-on-response>
</jbi:consumes>
</jbi:services>
</jbi:jbi>
{code}
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-4.0"
xmlns:sample="http://petals.ow2.org/sample"
xmlns:soap="http://petals.ow2.org/components/soap/version-3.1">
<!-- Import a Service into PEtALS or Expose a PEtALS Service => use a BC. -->
<jbi:services binding-component="true">
<!-- Import a Service into PEtALS => provides a Service. -->
<jbi:consumes interface-name="sample:SampleProvider"
service-name="sample:SampleProviderService"
endpoint-name="SampleProvider">
<!-- CDK specific fields -->
<petalsCDK:mep>InOut</petalsCDK:mep>
<petalsCDK:operation>${input_operation}</petalsCDK:operation>
<!-- SOAP specific fields -->
<soap:address>RESTService</soap:address>
<soap:mode>REST</soap:mode>
<soap:rest-add-namespace-uri>
http://petals.ow2.org/sample
</soap:rest-add-namespace-uri>
<soap:rest-add-namespace-prefix>ns1</soap:rest-add-namespace-prefix>
<soap:rest-remove-prefix-on-response>*</soap:rest-remove-prefix-on-response>
</jbi:consumes>
</jbi:services>
</jbi:jbi>
{code}
Each request to the REST URI {{http://<host>:<port>/petals/services/RESTService/}} will be forwarded to the SampleProviderEndpoint JBI endpoint.
An incoming request on the URL {{http://<host>:<port>/petals/services/RESTService/myOperation?param1=value1¶m2=value2}} in GET mode will produce the following JBI message :
{code:lang=xml}
<myOperation>
<param1>value1</param1>
<param2>value2</param2>
</myOperation>
{code}
With the {{rest.add-namespace-*}} parameters specified in the previous configuration, the JBI message will be like :
{code:lang=xml}
<ns1:myOperation xmlns:ns1="http://petals.ow2.org/sample">
<ns1:param1>value1</ns1:param1>
<ns1:param2>value2</ns1:param2>
</ns1:myOperation>
{code}
Let's suppose that the JBI service returns a JBI response like :
{code:lang=xml}
<ns1:Response xmlns:ns1="http://petals.ow2.org/sample1"
xmlns:ns2="http://petals.ow2.org/sample2"
xmlns:ns3="http://petals.ow2.org/sample3">
<ns1:param1>value1</ns1:param1>
<ns2:param2>value2</ns2:param2>
<ns3:param3>value3</ns3:param3>
</ns1:Response>
{code}
If the {{rest.remove-prefix-on-response}} parameter is set to 'ns1,ns2', the message returned to the REST service consumer will be :
{code:lang=xml}
<Response xmlns:ns1="http://petals.ow2.org/sample1"
xmlns:ns2="http://petals.ow2.org/sample2"
xmlns:ns3="http://petals.ow2.org/sample3">
<param1>value1</param1>
<param2>value2</param2>
<ns3:param3>value3</ns3:param3>
</Response>
{code}
If the {{rest.remove-prefix-on-response}} parameter is set to '*', the message returned to the REST service consumer will be :
{code:lang=xml}
<Response xmlns:ns1="http://petals.ow2.org/sample1"
xmlns:ns2="http://petals.ow2.org/sample2"
xmlns:ns3="http://petals.ow2.org/sample3">
<param1>value1</param1>
<param2>value2</param2>
<param3>value3</param3>
</Response>
{code}
An incoming request on the URL {{http://<host>:<port>/petals/services/RESTService/myOperation?param1=value1¶m2=value2}} in GET mode will produce the following JBI message :
{code:lang=xml}
<myOperation>
<param1>value1</param1>
<param2>value2</param2>
</myOperation>
{code}
With the {{rest.add-namespace-*}} parameters specified in the previous configuration, the JBI message will be like :
{code:lang=xml}
<ns1:myOperation xmlns:ns1="http://petals.ow2.org/sample">
<ns1:param1>value1</ns1:param1>
<ns1:param2>value2</ns1:param2>
</ns1:myOperation>
{code}
Let's suppose that the JBI service returns a JBI response like :
{code:lang=xml}
<ns1:Response xmlns:ns1="http://petals.ow2.org/sample1"
xmlns:ns2="http://petals.ow2.org/sample2"
xmlns:ns3="http://petals.ow2.org/sample3">
<ns1:param1>value1</ns1:param1>
<ns2:param2>value2</ns2:param2>
<ns3:param3>value3</ns3:param3>
</ns1:Response>
{code}
If the {{rest.remove-prefix-on-response}} parameter is set to 'ns1,ns2', the message returned to the REST service consumer will be :
{code:lang=xml}
<Response xmlns:ns1="http://petals.ow2.org/sample1"
xmlns:ns2="http://petals.ow2.org/sample2"
xmlns:ns3="http://petals.ow2.org/sample3">
<param1>value1</param1>
<param2>value2</param2>
<ns3:param3>value3</ns3:param3>
</Response>
{code}
If the {{rest.remove-prefix-on-response}} parameter is set to '*', the message returned to the REST service consumer will be :
{code:lang=xml}
<Response xmlns:ns1="http://petals.ow2.org/sample1"
xmlns:ns2="http://petals.ow2.org/sample2"
xmlns:ns3="http://petals.ow2.org/sample3">
<param1>value1</param1>
<param2>value2</param2>
<param3>value3</param3>
</Response>
{code}
h1. Web Service Notifications