You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by mnereson <mi...@gmail.com> on 2007/10/15 19:56:05 UTC

override binding name

Is there a way to override the binding name property?

For example

    <service xmlns="http://xfire.codehaus.org/config/1.0">
        <name>MyFulfillmentService</name>
        <serviceClass>
            com.myco.myapp.MyFulfillmentServiceImpl
        </serviceClass>
        <serviceFactory>#jsr181ServiceFactory</serviceFactory>
    </service>

Results in a binding named MyFulfillmentServiceHttpBinding

The wsdl shows

<wsdl:binding name="MyFulfillmentServiceHttpBinding"
type="tns:MyFulfillmentServicePortType">
   ... 
</wsdl:binding>

However, Our lightweight enterprise service bus requires the binding name to
be SomethingSoapBinding so I need MyFulfillmentServiceSoapBinding. 

My current configuration uses annotations and resembles the following:

=== services.xml ===

<beans>

    <bean name="jsr181ServiceFactory"
          class="org.codehaus.xfire.annotations.AnnotationServiceFactory">

        <constructor-arg ref="xfire.transportManager"
                        
type="org.codehaus.xfire.transport.TransportManager"
                         index="0"/>

        <constructor-arg ref="config" index="1"
                        
type="org.codehaus.xfire.aegis.type.Configuration"/>
    </bean>

    <bean id="config" class="org.codehaus.xfire.aegis.type.Configuration">
        <property name="defaultNillable" value="true"/>
        <property name="defaultMinOccurs" value="1"/>
    </bean>

    <service xmlns="http://xfire.codehaus.org/config/1.0">
        <name>MyFulfillmentService</name>
        <serviceClass>
            com.myco.myapp.MtFulfillmentServiceImpl
        </serviceClass>
        <serviceFactory>#jsr181ServiceFactory</serviceFactory>
    </service>


</beans>


== web.xml ==

<web-app>

    <servlet>
        <servlet-name>XFireServlet</servlet-name>
        <display-name>XFire Servlet</display-name>
        <servlet-class>
            org.codehaus.xfire.transport.http.XFireConfigurableServlet
        </servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>XFireServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>

</web-app>


== excerpts RemoteFulfillmentServiceImpl.java ==

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public class MyFulfillmentServiceImpl implements MyFulfillmentService {

   // various private methods
  
   @WebMethod
    public String soemPublicMethod(final int someId) {
       // maybe a couple lines of code
    }
  
}


Thanks for the help.

~ mnereson



-- 
View this message in context: http://www.nabble.com/override-binding-name-tf4629168.html#a13218105
Sent from the cxf-user mailing list archive at Nabble.com.


Re: override binding name

Posted by Daniel Kulp <dk...@apache.org>.


On Friday 11 January 2008, fox_lubiky wrote:
> The documentation
> (http://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html) says you
> can provide your own binding factory:
 
Hm... I think that page is wrong.   The jaxws:binding points to a 
BindingConfiguration object.   It allows you to provide a bean that will 
be used to provide default configuration for the binding.   
Unfortunately, the binding name isn't one of them right now.   

I've just committed a change on trunk that would allow you to configure 
this.   If you create a bean of type 
org.apache.cxf.binding.soap.SoapBindingConfiguration, you should be able 
to set either the bindingName (type QName) or the bindingNamePrefix 
(String) property on it.     I'll try and get that merged into 2.0.4.

Dan


>
>   "You can specify the BindingFactory for this endpoint to use. This
> can be supplied using the Spring <bean
>   class="MyBindingFactory"/> syntax."
>
> Like this:
>
> 		<jaxws:binding>
> 			<bean class='...MySoapBindingFactory'/>
> 		</jaxws:binding>
>
> However, that gives the error:
>
>   Cannot convert value of type [demo.spring.NamedSoapBindingFactory]
> to required type
>   [org.apache.cxf.binding.BindingConfiguration] for property
> 'bindingConfig'
>
> Another possibility I'm considering is an interceptor that rewrites
> the WSDL returned to the client. Any suggestions on the correct way to
> handle this?
>
> Thanks,
>
> mnereson wrote:
> > Is there a way to override the binding name property?
> >
> > For example
> >
> >     <service xmlns="http://xfire.codehaus.org/config/1.0">
> >         <name>MyFulfillmentService</name>
> >         <serviceClass>
> >             com.myco.myapp.MyFulfillmentServiceImpl
> >         </serviceClass>
> >         <serviceFactory>#jsr181ServiceFactory</serviceFactory>
> >     </service>
> >
> > Results in a binding named MyFulfillmentServiceHttpBinding
> >
> > The wsdl shows
> >
> > <wsdl:binding name="MyFulfillmentServiceHttpBinding"
> > type="tns:MyFulfillmentServicePortType">
> >    ...
> > </wsdl:binding>
> >
> > However, Our lightweight enterprise service bus requires the binding
> > name to be SomethingSoapBinding so I need
> > MyFulfillmentServiceSoapBinding.
> >
> > My current configuration uses annotations and resembles the
> > following:
> >
> > === services.xml ===
> >
> > <beans>
> >
> >     <bean name="jsr181ServiceFactory"
> >          
> > class="org.codehaus.xfire.annotations.AnnotationServiceFactory">
> >
> >         <constructor-arg ref="xfire.transportManager"
> >
> > type="org.codehaus.xfire.transport.TransportManager"
> >                          index="0"/>
> >
> >         <constructor-arg ref="config" index="1"
> >
> > type="org.codehaus.xfire.aegis.type.Configuration"/>
> >     </bean>
> >
> >     <bean id="config"
> > class="org.codehaus.xfire.aegis.type.Configuration"> <property
> > name="defaultNillable" value="true"/>
> >         <property name="defaultMinOccurs" value="1"/>
> >     </bean>
> >
> >     <service xmlns="http://xfire.codehaus.org/config/1.0">
> >         <name>MyFulfillmentService</name>
> >         <serviceClass>
> >             com.myco.myapp.MtFulfillmentServiceImpl
> >         </serviceClass>
> >         <serviceFactory>#jsr181ServiceFactory</serviceFactory>
> >     </service>
> >
> >
> > </beans>
> >
> >
> > == web.xml ==
> >
> > <web-app>
> >
> >     <servlet>
> >         <servlet-name>XFireServlet</servlet-name>
> >         <display-name>XFire Servlet</display-name>
> >         <servlet-class>
> >            
> > org.codehaus.xfire.transport.http.XFireConfigurableServlet
> > </servlet-class>
> >     </servlet>
> >
> >     <servlet-mapping>
> >         <servlet-name>XFireServlet</servlet-name>
> >         <url-pattern>/services/*</url-pattern>
> >     </servlet-mapping>
> >
> > </web-app>
> >
> >
> > == excerpts RemoteFulfillmentServiceImpl.java ==
> >
> > import javax.jws.WebMethod;
> > import javax.jws.WebService;
> >
> > @WebService
> > public class MyFulfillmentServiceImpl implements
> > MyFulfillmentService {
> >
> >    // various private methods
> >
> >    @WebMethod
> >     public String soemPublicMethod(final int someId) {
> >        // maybe a couple lines of code
> >     }
> >
> > }
> >
> >
> > Thanks for the help.
> >
> > ~ mnereson



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: override binding name

Posted by fox_lubiky <fo...@trashmail.net>.
Hi,

I'm evaluating CXF as a possible replacement for Axis, and I have the same
problem (the client requires a particular SOAP binding name in the WSDL).
The "SoapBinding" name seems to be hard-coded in SoapBindingFactory:

        SoapBindingInfo info = new SoapBindingInfo(si,
                                                   bindingid,
                                                   config.getVersion());

        info.setName(new QName(si.getName().getNamespaceURI(),
                               si.getName().getLocalPart() +
"SoapBinding"));

The documentation
(http://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html) says you can
provide your own binding factory:

  "You can specify the BindingFactory for this endpoint to use. This can be
supplied using the Spring <bean 
  class="MyBindingFactory"/> syntax."

Like this:

		<jaxws:binding>
			<bean class='...MySoapBindingFactory'/>
		</jaxws:binding>

However, that gives the error:

  Cannot convert value of type [demo.spring.NamedSoapBindingFactory] to
required type 
  [org.apache.cxf.binding.BindingConfiguration] for property 'bindingConfig'

Another possibility I'm considering is an interceptor that rewrites the WSDL
returned to the client. Any suggestions on the correct way to handle this?

Thanks,



mnereson wrote:
> 
> Is there a way to override the binding name property?
> 
> For example
> 
>     <service xmlns="http://xfire.codehaus.org/config/1.0">
>         <name>MyFulfillmentService</name>
>         <serviceClass>
>             com.myco.myapp.MyFulfillmentServiceImpl
>         </serviceClass>
>         <serviceFactory>#jsr181ServiceFactory</serviceFactory>
>     </service>
> 
> Results in a binding named MyFulfillmentServiceHttpBinding
> 
> The wsdl shows
> 
> <wsdl:binding name="MyFulfillmentServiceHttpBinding"
> type="tns:MyFulfillmentServicePortType">
>    ... 
> </wsdl:binding>
> 
> However, Our lightweight enterprise service bus requires the binding name
> to be SomethingSoapBinding so I need MyFulfillmentServiceSoapBinding. 
> 
> My current configuration uses annotations and resembles the following:
> 
> === services.xml ===
> 
> <beans>
> 
>     <bean name="jsr181ServiceFactory"
>           class="org.codehaus.xfire.annotations.AnnotationServiceFactory">
> 
>         <constructor-arg ref="xfire.transportManager"
>                         
> type="org.codehaus.xfire.transport.TransportManager"
>                          index="0"/>
> 
>         <constructor-arg ref="config" index="1"
>                         
> type="org.codehaus.xfire.aegis.type.Configuration"/>
>     </bean>
> 
>     <bean id="config" class="org.codehaus.xfire.aegis.type.Configuration">
>         <property name="defaultNillable" value="true"/>
>         <property name="defaultMinOccurs" value="1"/>
>     </bean>
> 
>     <service xmlns="http://xfire.codehaus.org/config/1.0">
>         <name>MyFulfillmentService</name>
>         <serviceClass>
>             com.myco.myapp.MtFulfillmentServiceImpl
>         </serviceClass>
>         <serviceFactory>#jsr181ServiceFactory</serviceFactory>
>     </service>
> 
> 
> </beans>
> 
> 
> == web.xml ==
> 
> <web-app>
> 
>     <servlet>
>         <servlet-name>XFireServlet</servlet-name>
>         <display-name>XFire Servlet</display-name>
>         <servlet-class>
>             org.codehaus.xfire.transport.http.XFireConfigurableServlet
>         </servlet-class>
>     </servlet>
> 
>     <servlet-mapping>
>         <servlet-name>XFireServlet</servlet-name>
>         <url-pattern>/services/*</url-pattern>
>     </servlet-mapping>
> 
> </web-app>
> 
> 
> == excerpts RemoteFulfillmentServiceImpl.java ==
> 
> import javax.jws.WebMethod;
> import javax.jws.WebService;
> 
> @WebService
> public class MyFulfillmentServiceImpl implements MyFulfillmentService {
> 
>    // various private methods
>   
>    @WebMethod
>     public String soemPublicMethod(final int someId) {
>        // maybe a couple lines of code
>     }
>   
> }
> 
> 
> Thanks for the help.
> 
> ~ mnereson
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/override-binding-name-tp13218105p14760134.html
Sent from the cxf-user mailing list archive at Nabble.com.