You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by na...@apache.org on 2008/07/25 14:14:10 UTC
svn commit: r679776 - in
/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2:
Axis2ServiceProvider.java TuscanyListingAgent.java
Author: nash
Date: Fri Jul 25 05:14:10 2008
New Revision: 679776
URL: http://svn.apache.org/viewvc?rev=679776&view=rev
Log:
Fix TUSCANY-2480
Modified:
tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java
Modified: tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java?rev=679776&r1=679775&r2=679776&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java (original)
+++ tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java Fri Jul 25 05:14:10 2008
@@ -65,7 +65,6 @@
import org.apache.axis2.description.WSDLToAxisServiceBuilder;
import org.apache.axis2.engine.ListenerManager;
import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.transport.http.server.HttpUtils;
import org.apache.axis2.transport.jms.JMSConstants;
import org.apache.axis2.transport.jms.JMSListener;
import org.apache.axis2.transport.jms.JMSSender;
@@ -124,7 +123,6 @@
private List<PolicyHandlerTuple> policyHandlerClassnames = null;
private List<PolicyHandler> policyHandlerList = new ArrayList<PolicyHandler>();
private Map<String, Port> urlMap = new HashMap<String, Port>();
- private Map<String, String> addressMap = new HashMap<String, String>();
public static final QName QNAME_WSA_ADDRESS =
new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS);
@@ -199,6 +197,27 @@
}
}
+ static String getPortAddress(Port port) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ return ((SOAPAddress)ext).getLocationURI();
+ }
+ if (ext instanceof SOAP12Address) {
+ return ((SOAP12Address)ext).getLocationURI();
+ }
+ return null;
+ }
+
+ static void setPortAddress(Port port, String locationURI) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ ((SOAPAddress)ext).setLocationURI(locationURI);
+ }
+ if (ext instanceof SOAP12Address) {
+ ((SOAP12Address)ext).setLocationURI(locationURI);
+ }
+ }
+
private String computeEndpointURI(String uri, ServletHost servletHost) {
if (uri == null) {
@@ -347,13 +366,6 @@
}
*/
- // remove it from the Axis context
- String modifiedURI = addressMap.remove(endpointURL);
- for (Object port : wsBinding.getService().getPorts().values()) {
- if (modifiedURI.equals(getPortAddress((Port)port))) {
- setPortAddress((Port)port, endpointURL);
- }
- }
configContext.getAxisConfiguration().removeService(stringURIPath);
}
} catch (URISyntaxException e) {
@@ -494,13 +506,6 @@
// addresses. To work around this, compute the values here.
Parameter modifyAddr = new Parameter("modifyUserWSDLPortAddress", "false");
axisService.addParameter(modifyAddr);
- String modifiedURL = setIPAddress(endpointURL);
- addressMap.put(endpointURL, modifiedURL);
- for (Object p : wsBinding.getService().getPorts().values()) {
- if (endpointURL.equals(getPortAddress((Port)p))) {
- setPortAddress((Port)p, modifiedURL);
- }
- }
return axisService;
}
@@ -575,39 +580,6 @@
}
}
- private String getPortAddress(Port port) {
- Object ext = port.getExtensibilityElements().get(0);
- if (ext instanceof SOAPAddress) {
- return ((SOAPAddress)ext).getLocationURI();
- }
- if (ext instanceof SOAP12Address) {
- return ((SOAP12Address)ext).getLocationURI();
- }
- return null;
- }
-
- private void setPortAddress(Port port, String locationURI) {
- Object ext = port.getExtensibilityElements().get(0);
- if (ext instanceof SOAPAddress) {
- ((SOAPAddress)ext).setLocationURI(locationURI);
- }
- if (ext instanceof SOAP12Address) {
- ((SOAP12Address)ext).setLocationURI(locationURI);
- }
- }
-
- private static String setIPAddress(String uriString) {
- try {
- URI uriObj = new URI(uriString);
- String ipAddr = HttpUtils.getIpAddress();
- String host = uriObj.getHost();
- return uriString.replace(host, ipAddr);
- } catch (Exception e) {
- // URI string not in expected format, so return it unmodified
- return uriString;
- }
- }
-
protected void initAxisOperations(AxisService axisService) {
for (Iterator<?> i = axisService.getOperations(); i.hasNext();) {
AxisOperation axisOp = (AxisOperation)i.next();
Modified: tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java?rev=679776&r1=679775&r2=679776&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java (original)
+++ tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java Fri Jul 25 05:14:10 2008
@@ -23,6 +23,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -52,6 +53,7 @@
import org.apache.axis2.description.Parameter;
import org.apache.axis2.description.PolicyInclude;
import org.apache.axis2.transport.http.ListingAgent;
+import org.apache.axis2.transport.http.server.HttpUtils;
import org.apache.axis2.util.ExternalPolicySerializer;
import org.apache.axis2.util.JavaUtils;
import org.apache.axis2.wsdl.WSDLConstants;
@@ -90,7 +92,8 @@
/**
* Override ?xsd processing so that WSDL documents with XSD imports
* and includes work correctly. When we move to Axis2 1.4, we may
- * be able to use SchemaSupplier to do this in a cleaner way.
+ * be able to use SchemaSupplier to do this in a cleaner way. Also
+ * ensure that the correct IP address and port are returned by ?wsdl.
*/
@Override
public void processListService(HttpServletRequest req,
@@ -99,6 +102,27 @@
String url = req.getRequestURL().toString();
String query = req.getQueryString();
+
+ // for ?wsdl requests, need to update the WSDL with correct IPaddr and port
+ int wsdl = query.indexOf("wsdl");
+ if (wsdl >= 0) {
+ String serviceName = extractServiceName(url);
+ HashMap services = configContext.getAxisConfiguration().getServices();
+ if ((services != null) && !services.isEmpty()) {
+ AxisService axisService = (AxisService)services.get(serviceName);
+ Parameter wsld4jdefinition = axisService.getParameter(WSDLConstants.WSDL_4_J_DEFINITION);
+ Definition definition = (Definition)wsld4jdefinition.getValue();
+ for (Object s : definition.getServices().values()) {
+ for (Object p : ((Service)s).getPorts().values()) {
+ String endpointURL = Axis2ServiceProvider.getPortAddress((Port)p);
+ String modifiedURL = setIPAddress(endpointURL, url);
+ Axis2ServiceProvider.setPortAddress((Port)p, modifiedURL);
+ }
+ }
+ }
+ }
+
+ // handle ?xsd requests here
int xsd = query.indexOf("xsd");
if (xsd >= 0) {
String serviceName = extractServiceName(url);
@@ -127,6 +151,7 @@
}
}
}
+
// in all other cases, delegate to the Axis2 code
super.processListService(req, res);
}
@@ -193,4 +218,21 @@
}
}
+ private static String setIPAddress(String wsdlURI, String requestURI) {
+ try {
+ URI wsdlURIObj = new URI(wsdlURI);
+ String wsdlHost = wsdlURIObj.getHost();
+ int wsdlPort = wsdlURIObj.getPort();
+ String wsdlAddr = wsdlHost + (wsdlPort != -1 ? ":" + Integer.toString(wsdlPort) : "");
+ URI requestURIObj = new URI(requestURI);
+ String ipAddr = HttpUtils.getIpAddress();
+ int requestPort = requestURIObj.getPort();
+ String newAddr = ipAddr + (requestPort != -1 ? ":" + Integer.toString(requestPort) : "");
+ return wsdlURI.replace(wsdlAddr, newAddr);
+ } catch (Exception e) {
+ // URI string not in expected format, so return the WSDL URI unmodified
+ return wsdlURI;
+ }
+ }
+
}