Hello all !
Pretty much as the author of this thread, we are upgrading our webservices
framework from XFire to CXF and we need to keep the contract unchanged.
I realized most of the changes can be avoided by using a Simple Frontend and
aegis binding and adding XFireCompatibilityServiceConfiguration service
configuration to the factory. By the way, I couldn't find any documentation
on how to do it with a simple frontend so here is how I did it :
<simple:server id="minimal" serviceClass="test.minimal.Minimal"
address="/minimal">
<simple:serviceBean>
<bean class="test.minimal.MinimalImpl" />
</simple:serviceBean>
<simple:dataBinding>
<bean class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
</simple:dataBinding>
<simple:serviceFactory>
<bean
class="org.apache.cxf.service.factory.ReflectionServiceFactoryBean">
<property name="serviceConfigurations">
<list>
<bean
class="org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfiguration"
/>
<bean
class="org.apache.cxf.service.factory.DefaultServiceConfiguration" />
</list>
</property>
</bean>
</simple:serviceFactory>
</simple:server>
Please advise if there was a better (less verbose ?) way to do it.
The above solve the qualification of parameters problems, and absence of the
"/" at the end of the namespace in XFire.
Next big problem was the name of the default parameters and return values
for the operations. This is how I solved it, but I thought it would be a lot
better if it is integrated into CXF :
//----------------------------------------------------------------
//MyXFireCompatibilityService.java
//----------------------------------------------------------------
package test.compatibility;
import java.lang.reflect.Method;
import javax.xml.namespace.QName;
import org.apache.cxf.service.factory.DefaultServiceConfiguration;
import org.apache.cxf.service.factory.ServiceConstructionException;
import org.apache.cxf.service.model.OperationInfo;
public class MyXFireCompatibilityService extends DefaultServiceConfiguration
{
public MyXFireCompatibilityService() {
}
@Override
public QName getInParameterName(OperationInfo op, Method method, int
paramNumber) {
return new QName(op.getName().getNamespaceURI(),
getDefaultLocalName(op, method, paramNumber,
"in"));
}
@Override
public QName getOutParameterName(OperationInfo op, Method method, int
paramNumber) {
return new QName(op.getName().getNamespaceURI(),
getDefaultLocalName(op, method, paramNumber,
"out"));
}
private String getDefaultLocalName(OperationInfo op, Method method, int
paramNumber, String prefix) {
Class<?> impl = getServiceFactory().getServiceClass();
// try to grab the implementation class so we can read the debug
symbols from it
if (impl != null) {
try {
method = impl.getMethod(method.getName(),
method.getParameterTypes());
} catch (Exception e) {
throw new ServiceConstructionException(e);
}
}
return DefaultServiceConfiguration.createName(method, paramNumber,
op.getInput()
.getMessageParts().size(), false, prefix);
}
//----------------------------------------------------------------
...And just replace the DefaultServiceConfiguration with this class in the
above xml configuration file.
Looks like it is working. I'd appreciate some confirmation on this.
Please note that :
1) I had to cut and paste getDefaultLocalName(), because the method is
private => maybe you CXF guys could make it protected...?
2) The only method in the (existing) XFireCompatibilityServiceConfiguration
could easily be added in the above class so we have to add only one service
configuration
What remains after these is some not-too-important differences about the
minOccurs and the nillable attributes in the schema, that should be quite
easily changeable in the same way as I changed default parameters names.
--
View this message in context:
http://old.nabble.com/XFire-migration---old-client-doesn%27t-send-named-parameters-tp22482409p28328837.html
Sent from the cxf-user mailing list archive at Nabble.com.