if (_isRPC) {
QName rpcWrapQName = new QName(bodyDef.getNamespaceURI(), rpcWrapper);
OMElement partWrapper = soapBody.getFirstChildWithName(rpcWrapQName);
if (partWrapper == null)
throw new OdeFault(__msgs.msgSoapBodyDoesNotContainExpectedPartWrapper(_serviceName,_portName,rpcWrapQName));
// In RPC the body element is the operation name, wrapping parts. Order doesn't really matter as far as
// we're concerned. All we need to do is copy the soap:body children, since doc-lit rpc looks the same
// in ode and soap.
for (Part pdef : bodyParts) {
OMElement srcPart = partWrapper.getFirstChildWithName(new QName(null, pdef.getName()));
if (srcPart == null)
throw new OdeFault(__msgs.msgSOAPBodyDoesNotContainRequiredPart(pdef.getName()));
message.appendChild(message.getOwnerDocument().importNode(OMUtils.toDOM(srcPart), true));
}
} else {
// In doc-literal style, we expect the elements in the body to correspond (in order) to the
// parts defined in the binding. All the parts should be element-typed, otherwise it is a mess.
Iterator<OMElement> srcParts = soapBody.getChildElements();
for (Part partDef : bodyParts) {
if (!srcParts.hasNext())
throw new OdeFault(__msgs.msgSOAPBodyDoesNotContainRequiredPart(partDef.getName()));
OMElement srcPart = srcParts.next();
if (partDef.getElementName() == null)
throw new OdeFault(__msgs.msgBindingDefinesNonElementDocListParts());
if (!srcPart.getQName().equals(partDef.getElementName()))
throw new OdeFault(__msgs.msgUnexpectedElementInSOAPBody(srcPart.getQName(), partDef.getElementName()));
Element destPart = message.getOwnerDocument().createElementNS(null, partDef.getName());
message.appendChild(destPart);
destPart.appendChild(message.getOwnerDocument().importNode(OMUtils.toDOM(srcPart), true));
}
}