You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2007/05/23 18:20:14 UTC
svn commit: r540988 - in
/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2:
Axis2WebServiceContainer.java AxisServiceGenerator.java WSDLQueryHandler.java
Author: gawor
Date: Wed May 23 09:20:11 2007
New Revision: 540988
URL: http://svn.apache.org/viewvc?view=rev&rev=540988
Log:
publish xsd/wsdl files appropriately. borrowed some code from cxf
Added:
geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java (with props)
Modified:
geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java?view=diff&rev=540988&r1=540987&r2=540988
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java (original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java Wed May 23 09:20:11 2007
@@ -19,29 +19,13 @@
import java.io.IOException;
import java.io.PrintWriter;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
import java.util.concurrent.CountDownLatch;
import javax.naming.Context;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.Service;
-import javax.wsdl.extensions.ExtensibilityElement;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.extensions.soap12.SOAP12Address;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLWriter;
-import javax.xml.namespace.QName;
-import javax.xml.ws.WebServiceException;
import org.apache.axiom.om.util.UUIDGenerator;
import org.apache.axis2.AxisFault;
@@ -53,14 +37,11 @@
import org.apache.axis2.context.OperationContext;
import org.apache.axis2.context.ServiceGroupContext;
import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.AxisServiceGroup;
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.engine.AxisEngine;
import org.apache.axis2.engine.DependencyManager;
import org.apache.axis2.engine.Handler.InvocationResponse;
-import org.apache.axis2.jaxws.description.builder.WsdlComposite;
-import org.apache.axis2.jaxws.description.builder.WsdlGenerator;
import org.apache.axis2.jaxws.server.JAXWSMessageReceiver;
import org.apache.axis2.transport.OutTransportInfo;
import org.apache.axis2.transport.RequestResponseTransport;
@@ -77,7 +58,6 @@
import org.apache.geronimo.jaxws.ServerJNDIResolver;
import org.apache.geronimo.webservices.WebServiceContainer;
import org.apache.geronimo.webservices.saaj.SAAJUniverse;
-import org.apache.ws.commons.schema.XmlSchema;
/**
* @version $Rev$ $Date$
@@ -96,6 +76,7 @@
protected JNDIResolver jndiResolver;
private AxisService service;
private URL configurationBaseUrl;
+ private WSDLQueryHandler wsdlQueryHandler;
public Axis2WebServiceContainer(PortInfo portInfo,
String endpointClassName,
@@ -106,6 +87,8 @@
this.endpointClassName = endpointClassName;
this.portInfo = portInfo;
this.configurationBaseUrl = configurationBaseUrl;
+
+
try {
configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
@@ -135,6 +118,8 @@
} catch (Exception e) {
throw new RuntimeException(e);
}
+
+ this.wsdlQueryHandler = new WSDLQueryHandler(this.service);
jndiResolver = new ServerJNDIResolver(context);
}
@@ -370,137 +355,40 @@
}
}
- class WSDLGeneratorImpl implements WsdlGenerator {
-
- private Definition def;
-
- public WSDLGeneratorImpl(Definition def) {
- this.def = def;
- }
-
- public WsdlComposite generateWsdl(String implClass, String bindingType) throws WebServiceException {
- // Need WSDL generation code
- WsdlComposite composite = new WsdlComposite();
- composite.setWsdlFileName(implClass);
- HashMap<String, Definition> testMap = new HashMap<String, Definition>();
- testMap.put(composite.getWsdlFileName(), def);
- composite.setWsdlDefinition(testMap);
- return composite;
- }
- }
-
- protected void processGetRequest(Request request, Response response, AxisService service, ConfigurationContext configurationContext, MessageContext msgContext) throws Exception{
- String servicePath = configurationContext.getServiceContextPath();
- //This is needed as some cases the servicePath contains two // at the beginning.
- while (servicePath.startsWith("/")) {
- servicePath = servicePath.substring(1);
- }
- final String contextPath = "/" + servicePath;
-
- URI uri = request.getURI();
- String path = uri.getPath();
- String serviceName = service.getName();
-
- if (!path.startsWith(contextPath)) {
- response.setStatusCode(301);
- response.setHeader("Location", contextPath);
- return;
- }
- if (uri.toString().indexOf("?") < 0) {
- if (!path.endsWith(contextPath)) {
- if (serviceName.indexOf("/") < 0) {
- String res = HTTPTransportReceiver.printServiceHTML(serviceName, configurationContext);
- PrintWriter pw = new PrintWriter(response.getOutputStream());
- pw.write(res);
- pw.flush();
- return;
- }
- }
- }
-
- //TODO: Has to implement
- if (uri.getQuery().startsWith("wsdl2")) {
- if (service != null) {
- service.printWSDL2(response.getOutputStream());
- return;
- }
- }
- if (uri.getQuery().startsWith("wsdl")) {
- if (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().equals("")) { //wsdl file has been provided
- Definition wsdlDefinition = new AxisServiceGenerator().getWSDLDefinition(portInfo, configurationBaseUrl, classLoader);
- if(wsdlDefinition != null){
- String portName = null;
- if(portInfo.getWsdlPort() != null) {
- portName = portInfo.getWsdlPort().getLocalPart();
- }
- QName qName = portInfo.getWsdlService();
- if (qName == null) {
- qName = new QName(service.getTargetNamespace(), service.getName());
- }
- if (portName == null) {
- portName = service.getEndpointName();
- }
- if(qName == null || portName == null) {
- log.info("Unable to call updateServices ["+ qName + "][" + portName +"]");
- } else {
- log.info("calling updateServices ["+ qName + "][" + portName +"]");
- updateServices(qName, portName, wsdlDefinition, request);
- }
- WSDLFactory factory = WSDLFactory.newInstance();
- WSDLWriter writer = factory.newWSDLWriter();
- writer.writeWSDL(wsdlDefinition, response.getOutputStream());
- return;
- }
- }else {
+ protected void processGetRequest(Request request, Response response, AxisService service, ConfigurationContext configurationContext, MessageContext msgContext) throws Exception{
+ if (request.getURI().getQuery() != null &&
+ (request.getURI().getQuery().startsWith("wsdl") ||
+ request.getURI().getQuery().startsWith("xsd"))) {
+ // wsdl or xsd request
+
+ if (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().equals("")) {
+ URL wsdlURL = AxisServiceGenerator.getWsdlURL(portInfo.getWsdlFile(),
+ configurationBaseUrl,
+ classLoader);
+ this.wsdlQueryHandler.writeResponse(request.getURI().toString(),
+ wsdlURL.toString(),
+ response.getOutputStream());
+ } else {
service.printWSDL(response.getOutputStream());
- return;
- }
- }
- //TODO: Not working properly and do we need to have these requests ?
- if (uri.getQuery().startsWith("xsd=")) {
- String schemaName = uri.getQuery().substring(uri.getQuery().lastIndexOf("=") + 1);
-
- if (service != null) {
- //run the population logic just to be sure
- service.populateSchemaMappings();
- //write out the correct schema
- Map schemaTable = service.getSchemaMappingTable();
- final XmlSchema schema = (XmlSchema) schemaTable.get(schemaName);
- //schema found - write it to the stream
- if (schema != null) {
- schema.write(response.getOutputStream());
- return;
- } else {
- // no schema available by that name - send 404
- response.setStatusCode(404);
- return;
- }
- }
- }
- //cater for named xsds - check for the xsd name
- if (uri.getQuery().startsWith("xsd")) {
- if (service != null) {
- response.setContentType("text/xml");
- response.setHeader("Transfer-Encoding", "chunked");
- service.printSchema(response.getOutputStream());
- response.getOutputStream().close();
- return;
}
- }
-
- msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
- msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, new Axis2TransportInfo(response));
-
- InvocationResponse processed = RESTUtil.processURLRequest(msgContext, response.getOutputStream(), null);
+ } else {
+ // REST request
+
+ msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
+ msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, new Axis2TransportInfo(response));
- if (!processed.equals(InvocationResponse.CONTINUE)) {
- response.setStatusCode(200);
- String s = HTTPTransportReceiver.getServicesHTML(configurationContext);
- PrintWriter pw = new PrintWriter(response.getOutputStream());
- pw.write(s);
- pw.flush();
+ InvocationResponse processed = RESTUtil.processURLRequest(msgContext,
+ response.getOutputStream(),
+ null);
+
+ if (!processed.equals(InvocationResponse.CONTINUE)) {
+ response.setStatusCode(200);
+ String s = HTTPTransportReceiver.getServicesHTML(configurationContext);
+ PrintWriter pw = new PrintWriter(response.getOutputStream());
+ pw.write(s);
+ pw.flush();
+ }
}
-
}
protected void setMsgContextProperties(MessageContext msgContext, AxisService service, Response response, Request request) {
@@ -549,70 +437,6 @@
contentType,
soapAction,
request.getURI().getPath());
- }
-
- private void updateServices(QName serviceName, String portName, Definition def, Request request)
- throws Exception {
- boolean updated = false;
- Map services = def.getServices();
- if (services != null) {
- Iterator serviceIterator = services.entrySet().iterator();
- while (serviceIterator.hasNext()) {
- Map.Entry serviceEntry = (Map.Entry) serviceIterator.next();
- QName currServiceName = (QName) serviceEntry.getKey();
- if (currServiceName.equals(serviceName)) {
- Service service = (Service) serviceEntry.getValue();
- updatePorts(portName, service, request);
- updated = true;
- } else {
- def.removeService(currServiceName);
- }
- }
- }
- if (!updated) {
- log.warn("WSDL '" + serviceName.getLocalPart() + "' service not found.");
- }
- }
-
- private void updatePorts(String portName, Service service, Request request)
- throws Exception {
- boolean updated = false;
- Map ports = service.getPorts();
- if (ports != null) {
- Iterator portIterator = ports.entrySet().iterator();
- while (portIterator.hasNext()) {
- Map.Entry portEntry = (Map.Entry) portIterator.next();
- String currPortName = (String) portEntry.getKey();
- if (currPortName.equals(portName)) {
- Port port = (Port) portEntry.getValue();
- updatePortLocation(request, port);
- updated = true;
- } else {
- service.removePort(currPortName);
- }
- }
- }
- if (!updated) {
- log.warn("WSDL '" + portName + "' port not found.");
- }
- }
-
- private void updatePortLocation(Request request, Port port) throws URISyntaxException {
- List<?> exts = port.getExtensibilityElements();
- if (exts != null && exts.size() > 0) {
- URI requestURI = request.getURI();
- URI serviceURI = new URI(requestURI.getScheme(), null,
- requestURI.getHost(), requestURI.getPort(),
- requestURI.getPath(), null, null);
- ExtensibilityElement el = (ExtensibilityElement) exts.get(0);
- if(el instanceof SOAP12Address){
- SOAP12Address add = (SOAP12Address)el;
- add.setLocationURI(serviceURI.toString());
- } else if (el instanceof SOAPAddress) {
- SOAPAddress add = (SOAPAddress)el;
- add.setLocationURI(serviceURI.toString());
- }
- }
}
}
Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java?view=diff&rev=540988&r1=540987&r2=540988
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java (original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java Wed May 23 09:20:11 2007
@@ -225,7 +225,7 @@
}
}
- private URL getWsdlURL(String wsdlFile, URL configurationBaseUrl, ClassLoader classLoader) {
+ public static URL getWsdlURL(String wsdlFile, URL configurationBaseUrl, ClassLoader classLoader) {
URL wsdlURL = null;
if (wsdlFile != null) {
Added: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java?view=auto&rev=540988
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java (added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java Wed May 23 09:20:11 2007
@@ -0,0 +1,293 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.axis2;
+
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.schema.SchemaImport;
+import javax.wsdl.extensions.schema.SchemaReference;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.axis2.description.AxisService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.webservices.WebServiceContainer.Request;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class WSDLQueryHandler {
+
+ private static final Log LOG = LogFactory.getLog(WSDLQueryHandler.class);
+
+ private Map<String, Definition> mp = new ConcurrentHashMap<String, Definition>();
+ private Map<String, SchemaReference> smp = new ConcurrentHashMap<String, SchemaReference>();
+ private AxisService service;
+
+ public WSDLQueryHandler(AxisService service) {
+ this.service = service;
+ }
+
+ public void writeResponse(String baseUri, String wsdlUri, OutputStream os) throws Exception {
+
+ int idx = baseUri.toLowerCase().indexOf("?wsdl");
+ String base = null;
+ String wsdl = "";
+ String xsd = null;
+ if (idx != -1) {
+ base = baseUri.substring(0, baseUri.toLowerCase().indexOf("?wsdl"));
+ wsdl = baseUri.substring(baseUri.toLowerCase().indexOf("?wsdl") + 5);
+ if (wsdl.length() > 0) {
+ wsdl = wsdl.substring(1);
+ }
+ } else {
+ base = baseUri.substring(0, baseUri.toLowerCase().indexOf("?xsd="));
+ xsd = baseUri.substring(baseUri.toLowerCase().indexOf("?xsd=") + 5);
+ }
+
+ if (!mp.containsKey(wsdl)) {
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.importDocuments", true);
+ reader.setFeature("javax.wsdl.verbose", false);
+ Definition def = reader.readWSDL(wsdlUri);
+ mp.put("", def);
+ updateDefinition(def, mp, smp, base);
+ updateServices(this.service.getName(), this.service.getEndpointName(), def, base);
+ }
+
+ Element rootElement;
+
+ if (xsd == null) {
+ Definition def = mp.get(wsdl);
+
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLWriter writer = factory.newWSDLWriter();
+
+ rootElement = writer.getDocument(def).getDocumentElement();
+ } else {
+ SchemaReference si = smp.get(xsd);
+ rootElement = si.getReferencedSchema().getElement();
+ }
+
+ NodeList nl = rootElement.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema",
+ "import");
+ for (int x = 0; x < nl.getLength(); x++) {
+ Element el = (Element) nl.item(x);
+ String sl = el.getAttribute("schemaLocation");
+ if (smp.containsKey(sl)) {
+ el.setAttribute("schemaLocation", base + "?xsd=" + sl);
+ }
+ }
+ nl = rootElement.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "include");
+ for (int x = 0; x < nl.getLength(); x++) {
+ Element el = (Element) nl.item(x);
+ String sl = el.getAttribute("schemaLocation");
+ if (smp.containsKey(sl)) {
+ el.setAttribute("schemaLocation", base + "?xsd=" + sl);
+ }
+ }
+ nl = rootElement.getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", "import");
+ for (int x = 0; x < nl.getLength(); x++) {
+ Element el = (Element) nl.item(x);
+ String sl = el.getAttribute("location");
+ if (mp.containsKey(sl)) {
+ el.setAttribute("location", base + "?wsdl=" + sl);
+ }
+ }
+
+ writeTo(rootElement, os);
+ }
+
+ protected void updateDefinition(Definition def,
+ Map<String, Definition> done,
+ Map<String, SchemaReference> doneSchemas,
+ String base) {
+ Collection<List> imports = def.getImports().values();
+ for (List lst : imports) {
+ List<Import> impLst = lst;
+ for (Import imp : impLst) {
+ String start = imp.getLocationURI();
+ try {
+ //check to see if it's aleady in a URL format. If so, leave it.
+ new URL(start);
+ } catch (MalformedURLException e) {
+ done.put(start, imp.getDefinition());
+ updateDefinition(imp.getDefinition(), done, doneSchemas, base);
+ }
+ }
+ }
+
+
+ /* This doesn't actually work. Setting setSchemaLocationURI on the import
+ * for some reason doesn't actually result in the new URI being written
+ * */
+ Types types = def.getTypes();
+ if (types != null) {
+ for (ExtensibilityElement el : (List<ExtensibilityElement>)types.getExtensibilityElements()) {
+ if (el instanceof Schema) {
+ Schema see = (Schema)el;
+ updateSchemaImports(see, doneSchemas, base);
+ }
+ }
+ }
+ }
+
+ protected void updateSchemaImports(Schema schema,
+ Map<String, SchemaReference> doneSchemas,
+ String base) {
+ Collection<List> imports = schema.getImports().values();
+ for (List lst : imports) {
+ List<SchemaImport> impLst = lst;
+ for (SchemaImport imp : impLst) {
+ String start = imp.getSchemaLocationURI();
+ if (start != null) {
+ try {
+ //check to see if it's aleady in a URL format. If so, leave it.
+ new URL(start);
+ } catch (MalformedURLException e) {
+ doneSchemas.put(start, imp);
+ updateSchemaImports(imp.getReferencedSchema(), doneSchemas, base);
+ }
+ }
+ }
+ }
+ List<SchemaReference> includes = schema.getIncludes();
+ for (SchemaReference included : includes) {
+ String start = included.getSchemaLocationURI();
+ if (start != null) {
+ try {
+ //check to see if it's aleady in a URL format. If so, leave it.
+ new URL(start);
+ } catch (MalformedURLException e) {
+ doneSchemas.put(start, included);
+ updateSchemaImports(included.getReferencedSchema(), doneSchemas, base);
+ }
+ }
+ }
+ }
+
+ public static void writeTo(Node node, OutputStream os) {
+ writeTo(new DOMSource(node), os);
+ }
+
+ public static void writeTo(Source src, OutputStream os) {
+ Transformer it;
+ try {
+ it = TransformerFactory.newInstance().newTransformer();
+ it.setOutputProperty(OutputKeys.METHOD, "xml");
+ it.setOutputProperty(OutputKeys.INDENT, "yes");
+ it.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
+ it.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "false");
+ it.setOutputProperty(OutputKeys.ENCODING, "utf-8");
+ it.transform(src, new StreamResult(os));
+ } catch (TransformerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private void updateServices(String serviceName, String portName, Definition def, String baseUri)
+ throws Exception {
+ boolean updated = false;
+ Map services = def.getServices();
+ if (services != null) {
+ Iterator serviceIterator = services.entrySet().iterator();
+ while (serviceIterator.hasNext()) {
+ Map.Entry serviceEntry = (Map.Entry) serviceIterator.next();
+ QName currServiceName = (QName) serviceEntry.getKey();
+ if (currServiceName.getLocalPart().equals(serviceName)) {
+ Service service = (Service) serviceEntry.getValue();
+ updatePorts(portName, service, baseUri);
+ updated = true;
+ } else {
+ def.removeService(currServiceName);
+ }
+ }
+ }
+ if (!updated) {
+ LOG.warn("WSDL '" + serviceName + "' service not found.");
+ }
+ }
+
+ private void updatePorts(String portName, Service service, String baseUri) throws Exception {
+ boolean updated = false;
+ Map ports = service.getPorts();
+ if (ports != null) {
+ Iterator portIterator = ports.entrySet().iterator();
+ while (portIterator.hasNext()) {
+ Map.Entry portEntry = (Map.Entry) portIterator.next();
+ String currPortName = (String) portEntry.getKey();
+ if (currPortName.equals(portName)) {
+ Port port = (Port) portEntry.getValue();
+ updatePortLocation(port, baseUri);
+ updated = true;
+ } else {
+ service.removePort(currPortName);
+ }
+ }
+ }
+ if (!updated) {
+ LOG.warn("WSDL '" + portName + "' port not found.");
+ }
+ }
+
+ private void updatePortLocation(Port port, String baseUri) throws URISyntaxException {
+ List<?> exts = port.getExtensibilityElements();
+ if (exts != null && exts.size() > 0) {
+ ExtensibilityElement el = (ExtensibilityElement) exts.get(0);
+ if (el instanceof SOAP12Address) {
+ SOAP12Address add = (SOAP12Address) el;
+ add.setLocationURI(baseUri);
+ } else if (el instanceof SOAPAddress) {
+ SOAPAddress add = (SOAPAddress) el;
+ add.setLocationURI(baseUri);
+ }
+ }
+ }
+}
Propchange: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/WSDLQueryHandler.java
------------------------------------------------------------------------------
svn:eol-style = native