}
public WebServiceBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
// Read a <binding.ws>
WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
/*IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
bindingType.setName(getArtifactType());
bindingType.setUnresolved(true);
((PolicySetAttachPoint)wsBinding).setType(bindingType);*/
wsBinding.setUnresolved(true);
wsBinding.setBuilder(new BindingBuilderImpl(extensionPoints));
// Read policies
policyProcessor.readPolicies(wsBinding, reader);
// Read the binding name
String name = reader.getAttributeValue(null, NAME);
if (name != null) {
wsBinding.setName(name);
}
// Read URI
String uri = reader.getAttributeValue(null, URI);
if (uri != null) {
wsBinding.setURI(uri);
}
// Read a qname in the form:
// namespace#wsdl.???(name)
Boolean wsdlElementIsBinding = null;
String wsdlElement = reader.getAttributeValue(null, WSDL_ELEMENT);
if (wsdlElement != null) {
int index = wsdlElement.indexOf('#');
if (index == -1) {
error("InvalidWsdlElementAttr", reader, wsdlElement);
//throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
return wsBinding;
}
String namespace = wsdlElement.substring(0, index);
wsBinding.setNamespace(namespace);
String localName = wsdlElement.substring(index + 1);
if (localName.startsWith("wsdl.service")) {
// Read a wsdl.service
localName = localName.substring("wsdl.service(".length(), localName.length() - 1);
wsBinding.setServiceName(new QName(namespace, localName));
} else if (localName.startsWith("wsdl.port")) {
// Read a wsdl.port
localName = localName.substring("wsdl.port(".length(), localName.length() - 1);
int s = localName.indexOf('/');
if (s == -1) {
error("InvalidWsdlElementAttr", reader, wsdlElement);
//throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
} else {
wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
wsBinding.setPortName(localName.substring(s + 1));
}
} else if (localName.startsWith("wsdl.endpoint")) {
// Read a wsdl.endpoint
localName = localName.substring("wsdl.endpoint(".length(), localName.length() - 1);
int s = localName.indexOf('/');
if (s == -1) {
error("InvalidWsdlElementAttr", reader, wsdlElement);
//throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
} else {
wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
wsBinding.setEndpointName(localName.substring(s + 1));
}
} else if (localName.startsWith("wsdl.binding")) {
// Read a wsdl.binding
localName = localName.substring("wsdl.binding(".length(), localName.length() - 1);
wsBinding.setBindingName(new QName(namespace, localName));
wsdlElementIsBinding = true;
} else {
error("InvalidWsdlElementAttr", reader, wsdlElement);
//throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
}
}
// Read wsdlLocation
wsBinding.setLocation(reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION));
ConfiguredOperation confOp = null;
// Skip to end element
while (reader.hasNext()) {
int event = reader.next();
switch (event) {
case START_ELEMENT: {
if (END_POINT_REFERENCE.equals(reader.getName().getLocalPart())) {
if (wsdlElement != null && (wsdlElementIsBinding == null || !wsdlElementIsBinding)) {
error("MustUseWsdlBinding", reader, wsdlElement);
throw new ContributionReadException(wsdlElement + " must use wsdl.binding when using wsa:EndpointReference");
}
wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader));
} else if (Constants.OPERATION_QNAME.equals(reader.getName())) {
confOp = configuredOperationProcessor.read(reader);
if (confOp != null) {
((OperationsConfigurator)wsBinding).getConfiguredOperations().add(confOp);
}