You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Milisic Aleksandar <ac...@yahoo.com.au> on 2010/09/21 07:46:28 UTC

Bindings and Transports programmatic configuration

Hi,

I'm interested in how to configure the bindings and transport for a service 
endpoint using the JaxWs Api.

I am using the JaxWsServerFactoryBean to publish a service. I see two methods 
that I believe are of interest - setBindingId(String bindingId) and 
setTransportId(String transportId).
Unfortunately, the parameters are just strings so they don't tell me much about 
this at all.

From my research so far, I have found the following:

Say I have the following common code:

JaxWsServerFactoryBean serverFactory = new JaxWsServerFactoryBean();
serverFactory.setServiceClass(someServiceClass.getClass());
serverFactory.setAddress(someddress);

The differences for the various bindings/transports would be:

1. Using SOAP 1.1 

 Would remain intact, no changes needed? Is this right?

2. Using SOAP1.2

//add line
serverFactory.setBindingId(SOAPBinding.SOAP12HTTP_BINDING);

3. Using Pure XML

//add line
serverFactory.setBindingId(XmlConstants.NS_XML_FORMAT);

4. Using SOAP/JMS

//add line
serverFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);


5. Using CORBA

//not sure?


I was hoping somebody could confirm what I have found in 1-5 and also help me 
fill in the gaps.

Another question was, in case of SoapBinding, I also would like to be able to 
configure other parameters using the API at the time of publishing (i.e. not 
with annotations).
These are:
1. The ParameterStyle, i.e. BARE or WRAPPED
2. Use, i.e. ENCODED or LITERAL and
3. Style, i.e RPC or DOCUMENT


Thanks in advance!



      

Re: Bindings and Transports programmatic configuration

Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 21 September 2010 1:46:28 am Milisic Aleksandar wrote:
> Hi,
> 
> I'm interested in how to configure the bindings and transport for a service
> endpoint using the JaxWs Api.
> 
> I am using the JaxWsServerFactoryBean to publish a service. I see two
> methods that I believe are of interest - setBindingId(String bindingId)
> and setTransportId(String transportId).
> Unfortunately, the parameters are just strings so they don't tell me much
> about this at all.
> 
> From my research so far, I have found the following:
> 
> Say I have the following common code:
> 
> JaxWsServerFactoryBean serverFactory = new JaxWsServerFactoryBean();
> serverFactory.setServiceClass(someServiceClass.getClass());
> serverFactory.setAddress(someddress);
> 
> The differences for the various bindings/transports would be:
> 
> 1. Using SOAP 1.1
> 
>  Would remain intact, no changes needed? Is this right?
> 
> 2. Using SOAP1.2
> 
> //add line
> serverFactory.setBindingId(SOAPBinding.SOAP12HTTP_BINDING);
> 
> 3. Using Pure XML
> 
> //add line
> serverFactory.setBindingId(XmlConstants.NS_XML_FORMAT);
> 
> 4. Using SOAP/JMS
> 
> //add line
> serverFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICIATION_TRANS
> PORTID);
> 
> 
> 5. Using CORBA
> 
> //not sure?
> 
> 
> I was hoping somebody could confirm what I have found in 1-5 and also help
> me fill in the gaps.

Well, there are a bunch of other options for those as well.  The best place to 
look is actually the **Factory things  (like SOAPTransportFactory, 
SOAPBindingFactory, CORBABindingFactory, etc...)  OR the META-INF/cxf/cxf-
extension-****.xml files.    They have defined namespaces that can be used.  
For example, for (5), the cxf-extension-corba.xml file defines:

				<value>http://cxf.apache.org/bindings/corba</value>
	        	<value>http://schemas.apache.org/yoko/bindings/corba</value>

and either of them can be used.  (the latter is historical as the CORBA 
binding originated from the Yoko project)  Also note: for the CORBA case, the 
binding and transport ID's would be the same as CORBA is both the binding and 
the transport.

 
> Another question was, in case of SoapBinding, I also would like to be able
> to configure other parameters using the API at the time of publishing
> (i.e. not with annotations).
> These are:
> 1. The ParameterStyle, i.e. BARE or WRAPPED
> 2. Use, i.e. ENCODED or LITERAL and
> 3. Style, i.e RPC or DOCUMENT

Well, #2 is not likely possible.   CXF doesn't support ENCODED at all so we 
PROBABLY have places where LITERAL is just hard coded.

For 1 and 3, you would need to create your own subclass of 
org.apache.cxf.service.factory.AbstractServiceConfiguration
and override whatever methods you want to control.   Then configure that into 
the ServiceFactoryBean in the JaxWsServerFactoryBean at the beginning of the 
ServiceConfiguration list.  Basically, the ReflectionServiceFactoryBean uses 
the list of ServiceConfiguration to retrieve pretty much all the information 
it needs.  JAX-WS has a subclass that gets that information from Annotations, 
but you can easily create your own that gets that information from elsewhere.


-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog