*/
private void copyExtensibleElements(List wsdl4jExtensibleElements,
Component component, Definition wsdl4jDefinition) {
Iterator iterator = wsdl4jExtensibleElements.iterator();
ExtensionFactory extensionFactory = this.wsdlComponentFactory
.createExtensionFactory();
while (iterator.hasNext()) {
ExtensibilityElement wsdl4jElement = (ExtensibilityElement) iterator
.next();
if (wsdl4jElement instanceof UnknownExtensibilityElement) {
UnknownExtensibilityElement unknown = (UnknownExtensibilityElement) (wsdl4jElement);
//look for the SOAP 1.2 stuff here. WSDL4j does not understand SOAP 1.2 things
if (ExtensionConstants.SOAP_12_OPERATION.equals(unknown.getElementType())){
org.apache.wsdl.extensions.SOAPOperation soapOperationExtensibiltyElement = (org.apache.wsdl.extensions.SOAPOperation) extensionFactory
.getExtensionElement(wsdl4jElement.getElementType());
Element element = unknown.getElement();
soapOperationExtensibiltyElement.setSoapAction(element.getAttribute("soapAction"));
soapOperationExtensibiltyElement.setStyle(element.getAttribute("style"));
// soapActionRequired
component.addExtensibilityElement(soapOperationExtensibiltyElement);
}else if (ExtensionConstants.SOAP_12_BODY.equals(unknown.getElementType())){
org.apache.wsdl.extensions.SOAPBody soapBodyExtensibiltyElement = (org.apache.wsdl.extensions.SOAPBody) extensionFactory
.getExtensionElement(wsdl4jElement.getElementType());
Element element = unknown.getElement();
soapBodyExtensibiltyElement.setUse(element.getAttribute("use"));
soapBodyExtensibiltyElement.setNamespaceURI(element.getAttribute("namespace"));
//encoding style
component.addExtensibilityElement(soapBodyExtensibiltyElement);
}else if (ExtensionConstants.SOAP_12_HEADER.equals(unknown.getElementType())){
org.apache.wsdl.extensions.SOAPHeader soapHeaderExtensibilityElement = (org.apache.wsdl.extensions.SOAPHeader) extensionFactory.getExtensionElement(
unknown.getElementType());
//right now there's no known header binding!. Ignore the copying of values for now
component.addExtensibilityElement(soapHeaderExtensibilityElement);
}else if (ExtensionConstants.SOAP_12_BINDING.equals(unknown.getElementType())){
org.apache.wsdl.extensions.SOAPBinding soapBindingExtensibiltyElement = (org.apache.wsdl.extensions.SOAPBinding) extensionFactory
.getExtensionElement(wsdl4jElement.getElementType());
Element element = unknown.getElement();
soapBindingExtensibiltyElement.setTransportURI(element.getAttribute("transport"));
soapBindingExtensibiltyElement.setStyle(element.getAttribute("style"));
component.addExtensibilityElement(soapBindingExtensibiltyElement);
} else if (ExtensionConstants.SOAP_12_ADDRESS.equals(unknown.getElementType())){
org.apache.wsdl.extensions.SOAPAddress soapAddressExtensibiltyElement = (org.apache.wsdl.extensions.SOAPAddress) extensionFactory
.getExtensionElement(wsdl4jElement.getElementType());
Element element = unknown.getElement();
soapAddressExtensibiltyElement.setLocationURI(element.getAttribute("location"));
component.addExtensibilityElement(soapAddressExtensibiltyElement);
} else if (ExtensionConstants.POLICY.equals(unknown.getElementType())) {
PolicyExtensibilityElement policyExtensibilityElement = (PolicyExtensibilityElement) extensionFactory.getExtensionElement(wsdl4jElement.getElementType());
DOMPolicyReader policyReader = (DOMPolicyReader) PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
policyExtensibilityElement.setPolicyElement(policyReader.readPolicy(unknown.getElement()));
component.addExtensibilityElement(policyExtensibilityElement);
} else if (ExtensionConstants.POLICY_REFERENCE.equals(unknown.getElementType())) {
PolicyExtensibilityElement policyExtensibilityElement = (PolicyExtensibilityElement) extensionFactory.getExtensionElement(wsdl4jElement.getElementType());
DOMPolicyReader policyReader = (DOMPolicyReader) PolicyFactory.getPolicyReader(PolicyFactory.DOM_POLICY_READER);
policyExtensibilityElement.setPolicyElement(policyReader.readPolicyReference(unknown.getElement()));
component.addExtensibilityElement(policyExtensibilityElement);
}else{
DefaultExtensibilityElement defaultExtensibilityElement = (DefaultExtensibilityElement) extensionFactory
.getExtensionElement(wsdl4jElement.getElementType());
defaultExtensibilityElement.setElement(unknown.getElement());
Boolean required = unknown.getRequired();
if (null != required) {
defaultExtensibilityElement.setRequired(required.booleanValue());
}
component.addExtensibilityElement(defaultExtensibilityElement);
}
} else if (wsdl4jElement instanceof SOAPAddress) {
SOAPAddress soapAddress = (SOAPAddress) wsdl4jElement;
org.apache.wsdl.extensions.SOAPAddress soapAddressExtensibilityElement = (org.apache.wsdl.extensions.SOAPAddress) extensionFactory
.getExtensionElement(soapAddress.getElementType());
soapAddressExtensibilityElement.setLocationURI(soapAddress
.getLocationURI());
Boolean required = soapAddress.getRequired();
if (null != required) {
soapAddressExtensibilityElement.setRequired(required.booleanValue());
}
component.addExtensibilityElement(soapAddressExtensibilityElement);
} else if (wsdl4jElement instanceof Schema) {
Schema schema = (Schema) wsdl4jElement;
//schema.getDocumentBaseURI()
//populate the imported schema stack
Stack schemaStack = new Stack();
//recursivly load the schema elements. The best thing is to push these into
//a stack and then pop from the other side
pushSchemaElement(schema, schemaStack);
org.apache.wsdl.extensions.Schema schemaExtensibilityElement = (org.apache.wsdl.extensions.Schema) extensionFactory.getExtensionElement(
schema.getElementType());
schemaExtensibilityElement.setElement(schema.getElement());
schemaExtensibilityElement.setImportedSchemaStack(schemaStack);
Boolean required = schema.getRequired();
if (null != required) {
schemaExtensibilityElement.setRequired(required.booleanValue());
}
//set the name of this Schema element
//todo this needs to be fixed
if(schema.getDocumentBaseURI() != null) {
schemaExtensibilityElement.setName(new QName("",schema.getDocumentBaseURI()));
}
component.addExtensibilityElement(schemaExtensibilityElement);
} else if (SOAPConstants.Q_ELEM_SOAP_OPERATION.equals(
wsdl4jElement.getElementType())) {
SOAPOperation soapOperation = (SOAPOperation) wsdl4jElement;
org.apache.wsdl.extensions.SOAPOperation soapOperationextensibilityElement = (org.apache.wsdl.extensions.SOAPOperation) extensionFactory.getExtensionElement(
soapOperation.getElementType());
soapOperationextensibilityElement.setSoapAction(
soapOperation.getSoapActionURI());
soapOperationextensibilityElement.setStyle(soapOperation.getStyle());
Boolean required = soapOperation.getRequired();
if (null != required) {
soapOperationextensibilityElement.setRequired(required.booleanValue());
}
component.addExtensibilityElement(soapOperationextensibilityElement);
} else if (SOAPConstants.Q_ELEM_SOAP_BODY.equals(
wsdl4jElement.getElementType())) {
SOAPBody soapBody = (SOAPBody) wsdl4jElement;
org.apache.wsdl.extensions.SOAPBody soapBodyExtensibilityElement = (org.apache.wsdl.extensions.SOAPBody) extensionFactory.getExtensionElement(
soapBody.getElementType());
soapBodyExtensibilityElement.setNamespaceURI(
soapBody.getNamespaceURI());
soapBodyExtensibilityElement.setUse(soapBody.getUse());
Boolean required = soapBody.getRequired();
if (null != required) {
soapBodyExtensibilityElement.setRequired(required.booleanValue());
}
component.addExtensibilityElement(soapBodyExtensibilityElement);
//add the header
} else if (SOAPConstants.Q_ELEM_SOAP_HEADER.equals(
wsdl4jElement.getElementType())) {
SOAPHeader soapHeader = (SOAPHeader) wsdl4jElement;
org.apache.wsdl.extensions.SOAPHeader soapHeaderExtensibilityElement = (org.apache.wsdl.extensions.SOAPHeader) extensionFactory.getExtensionElement(
soapHeader.getElementType());
soapHeaderExtensibilityElement.setNamespaceURI(
soapHeader.getNamespaceURI());
soapHeaderExtensibilityElement.setUse(soapHeader.getUse());
Boolean required = soapHeader.getRequired();
if (null != required) {
soapHeaderExtensibilityElement.setRequired(required.booleanValue());
}
if (null!=wsdl4jDefinition){
//find the relevant schema part from the messages
Message msg = wsdl4jDefinition.getMessage(soapHeader.getMessage());
Part msgPart = msg.getPart(soapHeader.getPart());
soapHeaderExtensibilityElement.setElement(msgPart.getElementName());
}
soapHeaderExtensibilityElement.setMessage(soapHeader.getMessage());
soapHeaderExtensibilityElement.setPart(soapHeader.getPart());
soapHeader.getMessage();
component.addExtensibilityElement(soapHeaderExtensibilityElement);
} else if (SOAPConstants.Q_ELEM_SOAP_BINDING.equals(
wsdl4jElement.getElementType())) {
SOAPBinding soapBinding = (SOAPBinding) wsdl4jElement;
org.apache.wsdl.extensions.SOAPBinding soapBindingExtensibilityElement = (org.apache.wsdl.extensions.SOAPBinding) extensionFactory.getExtensionElement(
soapBinding.getElementType());
soapBindingExtensibilityElement.setTransportURI(
soapBinding.getTransportURI());
soapBindingExtensibilityElement.setStyle(soapBinding.getStyle());
Boolean required = soapBinding.getRequired();