I have some 10 year old Java code for calling a legacy SOAP authentication service. The WSDL is RPC:ENCODED and contains many typos. I was hoping to easily convert the old code to Axis 1.4 or something, but ran into snags. Everything I looked at wanted to use the WSDL. Can someone help translate this into modern code that doesn’t require the faulty WSDL?
Here’s the SOAP call section:
SOAPMappingRegistry soapmappingregistry = new SOAPMappingRegistry();
BeanSerializer beanserializer = new BeanSerializer();
soapmappingregistry.mapTypes(Constants.NS_URI_SOAP_ENC, new QName(
"urn:xml-soap-session-demo", "authenticationresult"),
AuthenticationResult.class, beanserializer, beanserializer);
Call call = new Call();
call.setSOAPMappingRegistry(soapmappingregistry);
call.setTargetObjectURI("urn:Security");
call.setMethodName("authenticate");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector<Object> vector = new Vector<Object>();
vector.addElement(new Parameter("app", String.class, "PHS", null));
vector.addElement(new Parameter("user", String.class, userName, null));
vector.addElement(new Parameter("password", String.class, password, null));
vector.addElement(new Parameter("encryption", Integer.class, new Integer(0), null));
call.setParams(vector);
Response response = null;
URL endpointURL = new URL(endpoint);
response = call.invoke(endpointURL, "");
if (!response.generatedFault()) {
Parameter parameter = response.getReturnValue();
Object obj = parameter.getValue();
...
}
Many thanks.
Well, most soap frameworks relies on the WSDL standard a lot. Axis, CXF, Spring WS etc. I think you could try Spring WS. It has saved me a couple of times when you don’t know or want to use the entire WSDL (but knows how the payload should be encoded).
However, why do you even want to port that thing if the service is full of type-o:s? Old client, old service – why don’t you keep it that way and upgrade the code once the service has been replaced with something without type-o:s? I don’t think you will end up with something less ugly anyway.