Author: heiko.braun(a)jboss.com
Date: 2007-01-15 07:14:55 -0500 (Mon, 15 Jan 2007)
New Revision: 1961
Modified:
trunk/integration-jboss42/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml
trunk/integration-jboss50/src/main/resources/jbossws.deployer/META-INF/jbossws-deployer-beans.xml
trunk/jbossws-core/src/main/java/org/jboss/ws/core/CommonContextServlet.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpoint.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointManager.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
Log:
Fix JBWS-1399. Thanks for the contribution from Stefano Maestri
Modified:
trunk/integration-jboss42/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml
===================================================================
---
trunk/integration-jboss42/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml 2007-01-15
11:50:03 UTC (rev 1960)
+++
trunk/integration-jboss42/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml 2007-01-15
12:14:55 UTC (rev 1961)
@@ -13,7 +13,7 @@
If the content of <soap:address> is a valid URL, JBossWS will not rewrite
it unless 'alwaysModifySOAPAddress' is true.
If the content of <soap:address> is not a valid URL, JBossWS will rewrite
it using the attribute values given below.
- If 'webServiceHost' is an empty string, JBossWS uses requesters host when
rewriting the <soap:address>.
+ If next line (webServiceHost) is commented, JBossWS uses requesters protocolo,
host and port when rewriting the <soap:address>.
-->
<property
name="webServiceHost">${jboss.bind.address}</property>
<property name="webServiceSecurePort">8443</property>
Modified:
trunk/integration-jboss50/src/main/resources/jbossws.deployer/META-INF/jbossws-deployer-beans.xml
===================================================================
---
trunk/integration-jboss50/src/main/resources/jbossws.deployer/META-INF/jbossws-deployer-beans.xml 2007-01-15
11:50:03 UTC (rev 1960)
+++
trunk/integration-jboss50/src/main/resources/jbossws.deployer/META-INF/jbossws-deployer-beans.xml 2007-01-15
12:14:55 UTC (rev 1961)
@@ -11,7 +11,7 @@
If the content of <soap:address> is a valid URL, JBossWS will not rewrite
it unless 'alwaysModifySOAPAddress' is true.
If the content of <soap:address> is not a valid URL, JBossWS will rewrite
it using the attribute values given below.
- If 'webServiceHost' is an empty string, JBossWS uses requesters host when
rewriting the <soap:address>.
+ If next line (webServiceHost) is commented, JBossWS uses requesters protocolo,
host and port when rewriting the <soap:address>.
-->
<property
name="webServiceHost">${jboss.bind.address}</property>
<property name="webServiceSecurePort">8443</property>
Modified: trunk/jbossws-core/src/main/java/org/jboss/ws/core/CommonContextServlet.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/core/CommonContextServlet.java 2007-01-15
11:50:03 UTC (rev 1960)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/CommonContextServlet.java 2007-01-15
12:14:55 UTC (rev 1961)
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.io.PrintWriter;
+import java.net.URL;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -67,7 +68,8 @@
setupHTMLResponseHeader(writer);
writer.print("<body>");
- writer.print(epManager.showServiceEndpointTable());
+ //writer.print(epManager.showServiceEndpointTable());
+ writer.print(epManager.showServiceEndpointTable(new
URL(req.getRequestURL().toString())));
writer.print("</body>");
writer.print("</html>");
writer.close();
Modified: trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2007-01-15
11:50:03 UTC (rev 1960)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2007-01-15
12:14:55 UTC (rev 1961)
@@ -24,6 +24,7 @@
// $Id$
import java.io.StringWriter;
+import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
@@ -36,6 +37,7 @@
import org.jboss.ws.core.jaxrpc.binding.BindingException;
import org.jboss.ws.core.jaxrpc.binding.ComplexTypeSerializer;
import org.jboss.ws.core.jaxrpc.binding.SerializationContext;
+import org.jboss.ws.core.utils.JavaUtils;
import org.jboss.ws.extensions.xop.jaxws.AttachmentMarshallerImpl;
import org.w3c.dom.NamedNodeMap;
@@ -63,7 +65,29 @@
try
{
TypeMappingImpl typeMapping = serContext.getTypeMapping();
- Class javaType = typeMapping.getJavaType(xmlType);
+
+ Class javaType = null;
+ List<Class> possibleJavaTypes = typeMapping.getJavaTypes(xmlType);
+ if(possibleJavaTypes.size()>1)
+ {
+ // resolve java type by assignability
+ for(Class type : possibleJavaTypes)
+ {
+ if(JavaUtils.isAssignableFrom(type, value.getClass()))
+ {
+ javaType = value.getClass();
+ break;
+ }
+ }
+ }
+ else
+ {
+ javaType = typeMapping.getJavaType(xmlType);
+ }
+
+ if(null == javaType)
+ throw new Exception("Unable to resolve target java type");
+
JAXBContext jaxbContext = JAXBContext.newInstance(javaType);
Marshaller marshaller = jaxbContext.createMarshaller();
Modified: trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpoint.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpoint.java 2007-01-15
11:50:03 UTC (rev 1960)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpoint.java 2007-01-15
12:14:55 UTC (rev 1961)
@@ -134,7 +134,8 @@
ServiceEndpointInfo sepInfo = getServiceEndpointInfo();
EndpointMetaData epMetaData = sepInfo.getServerEndpointMetaData();
- String wsdlHost = reqURL.getHost();
+ //String wsdlHost = reqURL.getHost();
+ String wsdlHost = reqURL.getProtocol() + "://" + reqURL.getHost() +
":" + reqURL.getPort();
ServiceEndpointManagerFactory factory =
ServiceEndpointManagerFactory.getInstance();
ServiceEndpointManager epManager = factory.getServiceEndpointManager();
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointManager.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-01-15
11:50:03 UTC (rev 1960)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-01-15
12:14:55 UTC (rev 1961)
@@ -269,7 +269,7 @@
/** Show the registered webservices
*/
- public String showServiceEndpointTable()
+ public String showServiceEndpointTable(URL requestURL) throws
java.net.MalformedURLException
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
@@ -286,7 +286,15 @@
ServiceEndpoint wsEndpoint = (ServiceEndpoint)entry.getValue();
ServiceEndpointInfo seInfo = wsEndpoint.getServiceEndpointInfo();
String endpointAddress =
seInfo.getServerEndpointMetaData().getEndpointAddress();
- pw.println("<tr><td>" + sepID.getCanonicalName() +
"</td><td><a href='" + endpointAddress +
"?wsdl'>" + endpointAddress +
"?wsdl</a></td></tr>");
+ //pw.println("<tr><td>" + sepID.getCanonicalName() +
"</td><td><a href='" + endpointAddress +
"?wsdl'>" + endpointAddress +
"?wsdl</a></td></tr>");
+ URL displayURL = new URL(endpointAddress);
+ String endPointPath = displayURL.getPath();
+ if (this.getWebServiceHost().equals(ServiceEndpointManager.UNDEFINED_HOSTNAME)
== true)
+ {
+ displayURL = requestURL;
+ }
+ String displayAddress = displayURL.getProtocol() + "://" +
displayURL.getHost() + ":" + displayURL.getPort() + endPointPath;
+ pw.println("<tr><td>" + sepID.getCanonicalName() +
"</td><td><a href='" + displayAddress +
"?wsdl'>" + displayAddress +
"?wsdl</a></td></tr>");
}
pw.println("</table>");
pw.close();
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-01-15
11:50:03 UTC (rev 1960)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-01-15
12:14:55 UTC (rev 1961)
@@ -110,6 +110,8 @@
{
Element childElement = (Element)childNode;
String nodeName = childElement.getLocalName();
+
+ // Replace xsd:import location attributes
if ("import".equals(nodeName) ||
"include".equals(nodeName))
{
Attr locationAttr =
childElement.getAttributeNode("schemaLocation");
@@ -127,18 +129,24 @@
if (resPath != null && resPath.indexOf("/") >
0)
newResourcePath = resPath.substring(0,
resPath.lastIndexOf("/") + 1) + orgLocation;
- String reqProtocol = reqURL.getProtocol();
- int reqPort = reqURL.getPort();
- String hostAndPort = wsdlHost + (reqPort > 0 ? ":" +
reqPort : "");
String reqPath = reqURL.getPath();
-
- String newLocation = reqProtocol + "://" + hostAndPort +
reqPath + "?wsdl&resource=" + newResourcePath;
- locationAttr.setNodeValue(newLocation);
+ String completeHost = wsdlHost;
+ if (! wsdlHost.startsWith("http://") &&
wsdlHost.startsWith("https://"))
+ {
+ String reqProtocol = reqURL.getProtocol();
+ int reqPort = reqURL.getPort();
+ String hostAndPort = wsdlHost + (reqPort > 0 ? ":" +
reqPort : "");
+ completeHost = reqProtocol + "://" + hostAndPort;
+ }
+
+ String newLocation = completeHost + reqPath +
"?wsdl&resource=" + newResourcePath;
log.debug("Mapping import from '" + orgLocation +
"' to '" + newLocation + "'");
}
}
}
+
+ // Replace the soap:address location attribute
else if ("address".equals(nodeName))
{
Attr locationAttr = childElement.getAttributeNode("location");
@@ -149,12 +157,19 @@
URL locURL = new URL(orgLocation);
String locProtocol = locURL.getProtocol();
String locPath = locURL.getPath();
+
if (reqURL.getProtocol().equals(locProtocol) &&
reqURL.getPath().equals(locPath))
{
- int locPort = locURL.getPort();
- String hostAndPort = wsdlHost + (locPort > 0 ? ":" +
locPort : "");
-
- String newLocation = locProtocol + "://" + hostAndPort +
locPath;
+ String completeHost = wsdlHost;
+ if (!completeHost.startsWith("http://") ||
!completeHost.startsWith("https://"))
+ {
+ int locPort = locURL.getPort();
+ String hostAndPort = wsdlHost + (locPort > 0 ? ":" +
locPort : "");
+
+ completeHost = locProtocol + "://" + hostAndPort;
+ }
+
+ String newLocation = completeHost + locPath;
locationAttr.setNodeValue(newLocation);
log.debug("Mapping address from '" + orgLocation +
"' to '" + newLocation + "'");
Show replies by date