use of javax.wsdl.Part in project cxf by apache.
the class SoapBindingFactory method buildMessage.
private void buildMessage(MessageInfo minfo, javax.wsdl.Message msg, SchemaCollection schemas, int nextId, String partNameFilter) {
for (Part part : cast(msg.getParts().values(), Part.class)) {
if (StringUtils.isEmpty(partNameFilter) || part.getName().equals(partNameFilter)) {
if (StringUtils.isEmpty(part.getName())) {
throw new RuntimeException("Problem with WSDL: part element in message " + msg.getQName().getLocalPart() + " does not specify a name.");
}
QName pqname = new QName(minfo.getName().getNamespaceURI(), part.getName());
MessagePartInfo pi = minfo.getMessagePart(pqname);
if (pi != null && pi.getMessageInfo().getName().equals(msg.getQName())) {
continue;
}
pi = minfo.addOutOfBandMessagePart(pqname);
if (!minfo.getName().equals(msg.getQName())) {
pi.setMessageContainer(new MessageInfo(minfo.getOperation(), null, msg.getQName()));
}
if (part.getTypeName() != null) {
pi.setTypeQName(part.getTypeName());
pi.setElement(false);
pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName()));
} else {
pi.setElementQName(part.getElementName());
pi.setElement(true);
pi.setXmlSchema(schemas.getElementByQName(part.getElementName()));
}
pi.setProperty(OUT_OF_BAND_HEADER, Boolean.TRUE);
pi.setProperty(HEADER, Boolean.TRUE);
pi.setIndex(nextId);
nextId++;
}
}
}
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;
}
// RULE No.3:
// The output message part refers to a global element declaration
Part outputPart = null;
if (outputMessage != null && outputMessage.getParts().size() == 1) {
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;
}
// RULE No.4 and No5:
// wrapper element should be pure complex type
// Now lets see if we have any attributes...
// This should probably look at the restricted and substitute types too.
XmlSchemaComplexType xsct = null;
if (inputEl.getSchemaType() instanceof 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) {
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;
XmlSchemaType schemaType = 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();
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;
}
use of javax.wsdl.Part in project cxf by apache.
the class WSDLDefinitionBuilderTest method testBuildImportedWSDL.
@Test
public void testBuildImportedWSDL() throws Exception {
String wsdlUrl = getClass().getResource("hello_world_services.wsdl").toString();
WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(BusFactory.getDefaultBus());
Definition def = builder.build(wsdlUrl);
assertNotNull(def);
Map<?, ?> services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
String serviceQName = "http://apache.org/hello_world/services";
Service service = (Service) services.get(new QName(serviceQName, "SOAPService"));
assertNotNull(service);
Map<?, ?> ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Port port = service.getPort("SoapPort");
assertNotNull(port);
Binding binding = port.getBinding();
assertNotNull(binding);
QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding");
assertEquals(bindingQName, binding.getQName());
PortType portType = binding.getPortType();
assertNotNull(portType);
QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter");
assertEquals(portTypeQName, portType.getQName());
Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
assertNotNull(op1);
QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest");
assertEquals(messageQName, op1.getInput().getMessage().getQName());
Part part = op1.getInput().getMessage().getPart("in");
assertNotNull(part);
assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName());
}
Aggregations