use of javax.wsdl.Part in project cxf by apache.
the class ServiceWSDLBuilderTest method testNoBodyParts.
@Test
public void testNoBodyParts() throws Exception {
setupWSDL(NO_BODY_PARTS_WSDL_PATH);
QName messageName = new QName("urn:org:apache:cxf:no_body_parts/wsdl", "operation1Request");
Message message = newDef.getMessage(messageName);
Part part = message.getPart("mimeAttachment");
assertNotNull(part.getTypeName());
}
use of javax.wsdl.Part in project cxf by apache.
the class ServiceWSDLBuilder method buildMessage.
protected void buildMessage(Message message, AbstractMessageContainer messageContainer, final Definition def) {
addDocumentation(message, messageContainer.getMessageDocumentation());
message.setQName(messageContainer.getName());
message.setUndefined(false);
def.addMessage(message);
List<MessagePartInfo> messageParts = messageContainer.getMessageParts();
for (MessagePartInfo messagePartInfo : messageParts) {
final Part messagePart = def.createPart();
messagePart.setName(messagePartInfo.getName().getLocalPart());
if (messagePartInfo.isElement()) {
messagePart.setElementName(messagePartInfo.getElementQName());
addNamespace(messagePartInfo.getElementQName().getNamespaceURI(), def);
} else if (messagePartInfo.getTypeQName() != null) {
messagePart.setTypeName(messagePartInfo.getTypeQName());
addNamespace(messagePartInfo.getTypeQName().getNamespaceURI(), def);
}
message.addPart(messagePart);
}
}
use of javax.wsdl.Part in project cxf by apache.
the class WSDLParameter method processWrappedInputParams.
private void processWrappedInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs) throws Exception {
Input input = operation.getInput();
if (input != null) {
Message msg = input.getMessage();
Part part = (Part) msg.getOrderedParts(null).iterator().next();
XmlSchemaElement el = getElement(part, xmlSchemaList);
if (el == null) {
return;
}
XmlSchemaComplexType schemaType = null;
if (el.getSchemaType() != null) {
schemaType = (XmlSchemaComplexType) el.getSchemaType();
}
XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
if (seq != null) {
for (XmlSchemaSequenceMember seqItem : seq.getItems()) {
if (seqItem instanceof XmlSchemaElement) {
el = (XmlSchemaElement) seqItem;
// REVISIT, handle element ref's?
QName typeName = el.getSchemaTypeName();
if (typeName == null) {
typeName = el.getQName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, el.getSchemaType(), typeName, el.isNillable());
ParamType paramtype = createParam(wsdlToCorbaBinding, "in", el.getQName().getLocalPart(), idltype);
if (paramtype != null) {
inputs.add(paramtype);
}
}
}
}
}
}
use of javax.wsdl.Part in project cxf by apache.
the class WSDLParameter method isWrappedOperation.
private boolean isWrappedOperation(Operation op, SchemaCollection xmlSchemaList) throws Exception {
Message inputMessage = op.getInput().getMessage();
Message outputMessage = null;
if (op.getOutput() != null) {
outputMessage = op.getOutput().getMessage();
}
boolean passedRule = true;
// input message must exist
if (inputMessage == null || inputMessage.getParts().size() != 1 || (outputMessage != null && outputMessage.getParts().size() > 1)) {
passedRule = false;
}
if (!passedRule) {
return false;
}
XmlSchemaElement inputEl = null;
XmlSchemaElement outputEl = null;
// RULE No.2:
// The input message part refers to a global element decalration whose
// localname
// is equal to the operation name
Part inputPart = (Part) inputMessage.getParts().values().iterator().next();
if (inputPart.getElementName() == null) {
passedRule = false;
} else {
QName inputElementName = inputPart.getElementName();
inputEl = getElement(inputPart, xmlSchemaList);
if (inputEl == null || !op.getName().equals(inputElementName.getLocalPart())) {
passedRule = false;
}
}
if (!passedRule) {
return false;
}
// The output message part refers to a global element declaration
if (outputMessage != null && outputMessage.getParts().size() == 1) {
Part outputPart = (Part) outputMessage.getParts().values().iterator().next();
if (outputPart != null) {
if ((outputPart.getElementName() == null) || getElement(outputPart, xmlSchemaList) == null) {
passedRule = false;
} else {
outputEl = getElement(outputPart, xmlSchemaList);
}
}
}
if (!passedRule) {
return false;
}
if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaComplexType xsct = (XmlSchemaComplexType) inputEl.getSchemaType();
if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
passedRule = false;
}
} else {
passedRule = false;
}
if (!passedRule) {
return false;
}
if (outputMessage != null) {
if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaComplexType xsct = (XmlSchemaComplexType) outputEl.getSchemaType();
if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
passedRule = false;
}
} else {
passedRule = false;
}
}
return passedRule;
}
use of javax.wsdl.Part in project cxf by apache.
the class WSDLToCorbaBinding method convertFaultToCorbaType.
private CorbaType convertFaultToCorbaType(XmlSchema xmlSchema, Fault fault) throws Exception {
org.apache.cxf.binding.corba.wsdl.Exception corbaex = null;
Iterator<Part> parts = CastUtils.cast(fault.getMessage().getParts().values().iterator());
if (!parts.hasNext()) {
String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " UNSUPPORTED_FAULT.";
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
throw new Exception(msg.toString());
}
Part part = parts.next();
XmlSchemaType schemaType = helper.lookUpType(part);
if (schemaType != null) {
QName name = schemaType.getQName();
if (name == null) {
name = part.getElementName();
}
if (!helper.isSchemaTypeException(schemaType)) {
corbaex = new org.apache.cxf.binding.corba.wsdl.Exception();
String faultName = fault.getMessage().getQName().getLocalPart();
int pos = faultName.indexOf("_exception.");
if (pos != -1) {
faultName = faultName.substring(pos + 11);
faultName = faultName + "Exception";
}
QName faultMsgName = helper.createQNameCorbaNamespace(faultName);
corbaex.setName(faultName);
corbaex.setQName(faultMsgName);
CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, name, null, null, false);
if (corbaTypeImpl != null) {
MemberType member = new MemberType();
member.setName(corbaTypeImpl.getQName().getLocalPart());
member.setIdltype(corbaTypeImpl.getQName());
if (corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified()) {
member.setQualified(true);
}
corbaex.getMember().add(member);
}
} else {
corbaex = createCorbaException(name, schemaType);
}
}
if (schemaType == null) {
String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " INCORRECT_FAULT_MSG.";
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
throw new Exception(msg.toString());
}
if (corbaex == null) {
String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " UNSUPPORTED_FAULT.";
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
throw new Exception(msg.toString());
}
// Set the repository ID for Exception
// add to CorbaTypeMapping
String repoId = WSDLToCorbaHelper.REPO_STRING + corbaex.getName().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION;
corbaex.setRepositoryID(repoId);
CorbaType corbaTypeImpl = corbaex;
if (!helper.isDuplicate(corbaTypeImpl)) {
CorbaType dup = helper.isDuplicateException(corbaTypeImpl);
if (dup != null) {
typeMappingType.getStructOrExceptionOrUnion().remove(dup);
typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
} else {
typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
}
}
return corbaex;
}
Aggregations