throws WSIFException {
Trc.entry(this, input, output, fault);
if (!prepared)
prepare(input, output);
Envelope msgEnv = new Envelope();
Body msgBody = new Body();
Vector vect = new Vector();
Iterator iterator =
operation.getInput().getMessage().getParts().keySet().iterator();
while (iterator.hasNext()) {
String partName = (String) iterator.next();
Object part = input.getObjectPart(partName);
String encoding = null;
if ("literal".equals(inputUse)) {
// Should also include namespace
encoding = "literal";
} else {
encoding = this.inputEncodingStyle;
}
PartSerializer partSerializer = null;
Object o =
portInstance.getSOAPMappingRegistry().querySerializer(
part.getClass(),
inputUse);
if (o instanceof PartSerializer) {
PartSerializer tmp = (PartSerializer) o;
try {
partSerializer =
(PartSerializer) tmp.getClass().newInstance();
} catch (InstantiationException e) {
Trc.ignoredException(e);
} catch (IllegalAccessException e) {
Trc.ignoredException(e);
}
partSerializer.setPart(part);
Part modelPart =
operation.getInput().getMessage().getPart(partName);
javax.xml.namespace.QName partType = modelPart.getTypeName();
if (partType == null)
partType = modelPart.getElementName();
partSerializer.setPartQName(partType);
} else // document with soap encoding - never been tried
{
partSerializer = new SOAPEncSerializerWrapper();
partSerializer.setPart(part);
(
(
SOAPEncSerializerWrapper) partSerializer)
.setTargetSerializer(
(Serializer) o);
}
Bean bean = new Bean(partSerializer.getClass(), partSerializer);
vect.add(bean);
}
// create message envelope and body
URL url = portInstance.getEndPoint();
Envelope env = null;
msgBody.setBodyEntries(vect);
msgEnv.setBody(msgBody);
SOAPTransport st = getTransport();
if (st instanceof SOAPJMSConnection) {
SOAPJMSConnection sjt = (SOAPJMSConnection) st;
sjt.setSyncTimeout(WSIFProperties.getSyncTimeout());
sjt.setAsyncTimeout(WSIFProperties.getAsyncTimeout());
}
if (inJmsPropVals != null && !inJmsPropVals.isEmpty()) {
checkForTimeoutProperties(st, inJmsPropVals);
((SOAPJMSConnection) st).setJmsProperties(inJmsPropVals);
}
//TODO docstyle headers
//setCallContext( call );
if ( url != null && !isHostInNonProxyProperty( url ) ) {
setSOAPProxy( st );
}
// create and send message
try {
Message msg = new Message();
if (st != null)
msg.setSOAPTransport(st);
Trc.event(
this,
"Invoking operation ",
getName(),
" url ",
url,
" soapaction ",
getSoapActionURI(),
" envelope ",
msgEnv,
" message ",
msg);
msg.send(url, getSoapActionURI(), msgEnv);
// receive response envelope
env = msg.receiveEnvelope();
} catch (SOAPException exn) {
Trc.exception(exn);
WSIFException e =
new WSIFException("SOAP Exception: " + exn.getMessage());
e.setTargetException(exn);
throw e;
}
Trc.event(this, "Returned from operation, envelope ", env);
Body retbody = env.getBody();
java.util.Vector v = retbody.getBodyEntries();
int index = 0;
String encoding = null;
if ("literal".equals(outputUse)) {
// Should also include namespace
encoding = "literal";
} else {
encoding = this.outputEncodingStyle;
}
iterator =
operation.getOutput().getMessage().getParts().keySet().iterator();
while (iterator.hasNext()) {
Element element = (Element) v.get(index++);
String partName = (String) iterator.next();
Part modelPart =
operation.getOutput().getMessage().getPart(partName);
javax.xml.namespace.QName partType = modelPart.getTypeName();
if (partType == null)
partType = modelPart.getElementName();
PartSerializer partSerializer = null;
Object o =
this.portInstance.getSOAPMappingRegistry().queryDeserializer(
new org.apache.soap.util.xml.QName(
partType.getNamespaceURI(),
partType.getLocalPart()),
encoding);
if (o instanceof PartSerializer) {
PartSerializer tmp = (PartSerializer) o;
try {
partSerializer =
(PartSerializer) tmp.getClass().newInstance();
} catch (InstantiationException e) {
Trc.ignoredException(e);
} catch (IllegalAccessException e) {
Trc.ignoredException(e);
}
partSerializer.setPartQName(partType);
partSerializer.unmarshall(null, null, element, null, null);
Object retBean = partSerializer.getPart();
output.setObjectPart(partName, retBean);
} else // document with soap encoding - never been tried
{
Bean bean =
((Deserializer) o).unmarshall(
null,
null,
element,
null,
null);
Object retBean = bean.value;
}
}
Header soapHeader = env.getHeader();
addContextResponseSOAPHeaders(soapHeader);
Trc.exit(true);
return true;
}