summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.3/modules/binding-ws-axis2
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-1.3/modules/binding-ws-axis2')
-rw-r--r--branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java70
-rw-r--r--branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java44
2 files changed, 64 insertions, 50 deletions
diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
index de6f7c2c21..832e1a0cca 100644
--- a/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
+++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
@@ -73,7 +73,6 @@ import org.apache.axis2.description.WSDL2Constants;
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;
@@ -132,7 +131,6 @@ public class Axis2ServiceProvider {
private Map<ClassLoader, 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);
@@ -207,6 +205,27 @@ public class Axis2ServiceProvider {
}
}
+ 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) {
@@ -355,13 +374,6 @@ public class Axis2ServiceProvider {
}
*/
- // 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) {
@@ -502,13 +514,6 @@ public class Axis2ServiceProvider {
// 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;
}
@@ -581,39 +586,6 @@ public class Axis2ServiceProvider {
}
}
- 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();
diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java b/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java
index 2342e7f6ef..21fef3e5d8 100644
--- a/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java
+++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java
@@ -23,6 +23,7 @@ import java.io.IOException;
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.AxisService;
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 @@ public class TuscanyListingAgent extends ListingAgent {
/**
* 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 @@ public class TuscanyListingAgent extends ListingAgent {
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 @@ public class TuscanyListingAgent extends ListingAgent {
}
}
}
+
// in all other cases, delegate to the Axis2 code
super.processListService(req, res);
}
@@ -193,4 +218,21 @@ public class TuscanyListingAgent extends ListingAgent {
}
}
+ 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;
+ }
+ }
+
}