From scm-return-6353-apmail-geronimo-scm-archive=geronimo.apache.org@geronimo.apache.org Fri Mar 18 07:34:20 2005 Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 65220 invoked from network); 18 Mar 2005 07:34:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 18 Mar 2005 07:34:20 -0000 Received: (qmail 62438 invoked by uid 500); 18 Mar 2005 07:34:19 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 62407 invoked by uid 500); 18 Mar 2005 07:34:19 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 62394 invoked by uid 99); 18 Mar 2005 07:34:18 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 17 Mar 2005 23:34:17 -0800 Received: (qmail 65194 invoked by uid 65534); 18 Mar 2005 07:34:16 -0000 Message-ID: <20050318073416.65193.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Fri, 18 Mar 2005 07:34:16 -0000 Subject: svn commit: r158026 - in geronimo/trunk/modules/axis/src: java/org/apache/geronimo/axis/server/AxisWebServiceContainer.java test/org/apache/geronimo/axis/AxisRequest.java test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java To: scm@geronimo.apache.org From: chirino@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: chirino Date: Thu Mar 17 23:34:13 2005 New Revision: 158026 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D158026 Log: Implemented WSDL port address replacment. Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/Ax= isWebServiceContainer.java geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisReque= st.java geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebSe= rviceContainerTest.java Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/ser= ver/AxisWebServiceContainer.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org= /apache/geronimo/axis/server/AxisWebServiceContainer.java?view=3Ddiff&r1=3D= 158025&r2=3D158026 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/Ax= isWebServiceContainer.java (original) +++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/Ax= isWebServiceContainer.java Thu Mar 17 23:34:13 2005 @@ -20,8 +20,18 @@ import java.io.OutputStream; import java.net.URI; import java.net.URL; +import java.util.Iterator; +import java.util.Map; =20 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.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.wsdl.xml.WSDLWriter; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPMessage; =20 @@ -51,6 +61,11 @@ protected final URL wsdlURL; protected final SOAPService service; //TODO why did i make these prot= ected? private final ClassLoader classLoader; + private final Object wsdlMutext =3D new Object(); + + private Definition definition; + + private WSDLWriter wsdlWriter; =20 public AxisWebServiceContainer(URI location, URL wsdlURL, SOAPService = service, ClassLoader classLoader) { this.location =3D location; @@ -172,23 +187,59 @@ } return responseMessage; } - - public void getWsdl(Request req, Response res) throws Exception { - OutputStream out =3D res.getOutputStream(); - InputStream in =3D null; - try { - in =3D wsdlURL.openStream(); - byte[] buffer =3D new byte[1024]; - for (int read =3D in.read(buffer); read > 0; read =3D in.read(= buffer)) { -// System.out.write(buffer, 0, read); - out.write(buffer, 0, read); - } - } finally { - if (in !=3D null) { - in.close(); - } + =20 + public void getWsdl(Request request, Response response) throws Excepti= on { + =20 + // Avoid concurrent modification of the WSDL dom. + synchronized(wsdlMutext) { + =20 + // Read in the the WSDL in once.=20 + if( definition =3D=3D null ) { + initWSDLDom(); + } + =20 + // Update all the service port soap address elements. + Map services =3D definition.getServices(); + for (Iterator iter1 =3D services.values().iterator(); iter1.ha= sNext();) { + Service service =3D (Service) iter1.next(); + Map ports =3D service.getPorts(); + for (Iterator iter2 =3D ports.values().iterator(); iter2.h= asNext();) { + Port port =3D (Port) iter2.next(); + for (Iterator iter3 =3D port.getExtensibilityElements(= )=2Eiterator(); iter3.hasNext();) { + ExtensibilityElement element =3D (ExtensibilityEle= ment) iter3.next(); + if (element instanceof SOAPAddress ) { + SOAPAddress soapAddress =3D (SOAPAddress)eleme= nt; + URI realLocation =3D request.getURI(); = =20 + // We replace the host and port here. + URI updated =3D new URI( + realLocation.getScheme(), + realLocation.getUserInfo(),=20 + realLocation.getHost(),=20 + realLocation.getPort(), + realLocation.getPath(), // Humm is thi= s right? + null, + null); + soapAddress.setLocationURI(updated.toString()); + } + } + } + } + =20 + // Dump the WSDL dom to the output stream + OutputStream out =3D response.getOutputStream(); + wsdlWriter.writeWSDL(definition, out); + out.close(); } + } =20 + /** + * @throws Exception + */ + private void initWSDLDom() throws Exception { + WSDLFactory wsdlFactory =3D WSDLFactory.newInstance(); + wsdlWriter =3D wsdlFactory.newWSDLWriter(); + WSDLReader wsdlReader =3D wsdlFactory.newWSDLReader(); + definition =3D wsdlReader.readWSDL(wsdlURL.toExternalForm()); } =20 public URI getLocation() { Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/Axi= sRequest.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org= /apache/geronimo/axis/AxisRequest.java?view=3Ddiff&r1=3D158025&r2=3D158026 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisReque= st.java (original) +++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisReque= st.java Thu Mar 17 23:34:13 2005 @@ -2,7 +2,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; -import java.net.URL; import java.util.Map; =20 import org.apache.geronimo.webservices.WebServiceContainer; @@ -10,13 +9,10 @@ public class AxisRequest implements WebServiceContainer.Request { private int contentLength; private String contentType; - private String host; private InputStream in; private int method; private Map parameters; - private String path; private URI uri; - private int port; private Map headers; =20 /** @@ -25,22 +21,16 @@ public AxisRequest( int contentLength, String contentType, - String host, InputStream in, int method, Map parameters, - String path, URI uri, - int port, Map headers) { this.contentType =3D contentType; - this.host =3D host; this.in =3D in; this.method =3D method; this.parameters =3D parameters; - this.path =3D path; this.uri =3D uri; - this.port =3D port; this.headers =3D headers; } =20 @@ -56,10 +46,6 @@ return (String) headers.get(name); } =20 - public String getHost() { - return host; - } - public InputStream getInputStream() throws IOException { return in; } @@ -74,14 +60,6 @@ =20 public Map getParameters() { return parameters; - } - - public String getPath() { - return path; - } - - public int getPort() { - return port; } =20 public URI getURI() { Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/Axi= sWebServiceContainerTest.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org= /apache/geronimo/axis/AxisWebServiceContainerTest.java?view=3Ddiff&r1=3D158= 025&r2=3D158026 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebSe= rviceContainerTest.java (original) +++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebSe= rviceContainerTest.java Thu Mar 17 23:34:13 2005 @@ -110,13 +110,10 @@ new AxisRequest( 504, "text/xml; charset=3Dutf-8", - "127.0.0.1", in, 0, new HashMap(), - null, location, - 8080, new HashMap()); AxisResponse res =3D new AxisResponse("text/xml; charset=3Dutf-8", "127.0.0.1", nul= l, null, 8080, System.out);