in bindings/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java [331:404]
protected void overrideDefinition(Definition def) throws Exception {
PortType portType = getTargetPortType(def);
if (portType != null) {
QName[] names = (QName[])def.getPortTypes().keySet().toArray(new QName[0]);
for (int i = 0; i < names.length; i++) {
if (!names[i].equals(portType.getQName())) {
def.removePortType(names[i]);
}
}
names = (QName[])def.getServices().keySet().toArray(new QName[0]);
for (int i = 0; i < names.length; i++) {
def.removeService(names[i]);
}
names = (QName[])def.getBindings().keySet().toArray(new QName[0]);
for (int i = 0; i < names.length; i++) {
def.removeBinding(names[i]);
}
String location = getLocationURI();
if (!location.endsWith("/")) {
location += "/";
}
HttpComponent comp = (HttpComponent)getServiceUnit().getComponent();
if (comp.getConfiguration().isManaged()) {
// Save the path
String path = new URI(location).getPath();
location = "http://localhost";
if (comp.getHost() != null) {
if (comp.getProtocol() != null) {
location = comp.getProtocol() + "://";
} else {
location = "http://";
}
location += comp.getHost();
if (comp.getPort() != 80) {
location += ":" + comp.getPort();
}
if (comp.getPath() != null) {
location += comp.getPath();
}
}
location += comp.getConfiguration().getMapping() + path;
}
if (portType.getQName().getNamespaceURI().equals(service.getNamespaceURI())) {
if (isSoap()) {
PortTypeDecorator.decorate(def, portType, location, endpoint + "Binding", service
.getLocalPart(), endpoint, soapVersion);
definition = def;
} else {
Binding bnd = def.createBinding();
bnd.setPortType(portType);
bnd.setQName(new QName(service.getNamespaceURI(), endpoint + "Binding"));
bnd.setUndefined(false);
def.addBinding(bnd);
Port port = def.createPort();
port.setName(endpoint);
port.setBinding(bnd);
HTTPAddress address = new HTTPAddressImpl();
address.setLocationURI(location);
port.addExtensibilityElement(address);
def.addNamespace("http", "http://schemas.xmlsoap.org/wsdl/http/");
Service svc = def.createService();
svc.setQName(service);
svc.addPort(port);
def.addService(svc);
definition = def;
}
} else {
definition = PortTypeDecorator.createImportDef(def, service.getNamespaceURI(),
"porttypedef.wsdl");
PortTypeDecorator.decorate(definition, portType, location, endpoint + "Binding", service
.getLocalPart(), endpoint, soapVersion);
}
}
}