diff --git a/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java b/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java index 1bfaa7b6b..43266b77a 100644 --- a/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java +++ b/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java @@ -256,6 +256,8 @@ protected void writeFileBody(PrintWriter pw) throws IOException { writeGetPortName(pw, bindingType, portName); writeGetPortNameURL(pw, bindingType, portName, stubClass, wsddServiceName); + writeGetPortNameString(pw, bindingType, portName, stubClass, + wsddServiceName); writeSetPortEndpointAddress(pw, portName); } @@ -409,6 +411,36 @@ protected void writeGetPortNameURL(PrintWriter pw, String bindingType, pw.println(); } // writeGetPortNameURL + /** + * Write the get(String) method. + * + * @param pw + * @param bindingType + * @param portName + * @param stubClass + * @param wsddServiceName + */ + protected void writeGetPortNameString(PrintWriter pw, String bindingType, + String portName, String stubClass, + String wsddServiceName) { + + pw.println(" public " + bindingType + " get" + portName + + "(java.lang.String portAddress) throws " + + javax.xml.rpc.ServiceException.class.getName() + " {"); + pw.println(" try {"); + pw.println(" " + stubClass + " _stub = new " + stubClass + + "(portAddress, this);"); + pw.println(" _stub.setPortName(get" + wsddServiceName + + "());"); + pw.println(" return _stub;"); + pw.println(" }"); + pw.println(" catch (org.apache.axis.AxisFault e) {"); + pw.println(" return null;"); + pw.println(" }"); + pw.println(" }"); + pw.println(); + } // writeGetPortNameURL + /** * Write the setEndpointAddress(String) method. * diff --git a/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaStubWriter.java b/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaStubWriter.java index a93cd9864..83666a1d4 100644 --- a/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaStubWriter.java +++ b/axis-codegen/src/main/java/org/apache/axis/wsdl/toJava/JavaStubWriter.java @@ -187,6 +187,17 @@ protected void writeFileBody(PrintWriter pw) throws IOException { pw.println(" super.cachedEndpoint = endpointURL;"); pw.println(" }"); pw.println(); + pw.println( + " public " + className + + "(java.lang.String endpoint, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {"); + pw.println(" this(service);"); + pw.println(" try {"); + pw.println(" super.cachedEndpoint = org.apache.axis.utils.IOUtils.toURL(endpoint);"); + pw.println(" } catch (java.net.MalformedURLException ex) {"); + pw.println(" throw org.apache.axis.AxisFault.makeFault(ex);"); + pw.println(" }"); + pw.println(" }"); + pw.println(); pw.println( " public " + className + "(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {"); diff --git a/axis-rt-core/src/main/java/org/apache/axis/client/AdminClient.java b/axis-rt-core/src/main/java/org/apache/axis/client/AdminClient.java index 319d1459b..d06b8904a 100644 --- a/axis-rt-core/src/main/java/org/apache/axis/client/AdminClient.java +++ b/axis-rt-core/src/main/java/org/apache/axis/client/AdminClient.java @@ -21,6 +21,7 @@ import org.apache.axis.components.logger.LogFactory; import org.apache.axis.deployment.wsdd.WSDDConstants; import org.apache.axis.message.SOAPBodyElement; +import org.apache.axis.utils.IOUtils; import org.apache.axis.utils.Messages; import org.apache.axis.utils.Options; import org.apache.axis.utils.StringUtils; @@ -30,6 +31,7 @@ import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.InputStream; +import java.net.URI; import java.net.URL; import java.util.Vector; @@ -346,7 +348,7 @@ public void processOpts(Options opts) throws Exception { throw new Exception(Messages.getMessage("nullCall00")); } - URL address = new URL(opts.getURL()); + URI address = IOUtils.toURI(opts.getURL()); setTargetEndpointAddress(address); setLogin(opts.getUser(), opts.getPassword()); @@ -374,6 +376,15 @@ public void setTargetEndpointAddress(URL address) { call.setTargetEndpointAddress( address ); } + /** + * set the URL to deploy to + * requires that call!=null + * @param address + */ + public void setTargetEndpointAddress(URI address) { + call.setTargetEndpointAddress( address ); + } + /** * set the transport to deploy with. * requires that call!=null diff --git a/axis-rt-core/src/main/java/org/apache/axis/client/Call.java b/axis-rt-core/src/main/java/org/apache/axis/client/Call.java index 9a0ce97fa..80702ffd9 100644 --- a/axis-rt-core/src/main/java/org/apache/axis/client/Call.java +++ b/axis-rt-core/src/main/java/org/apache/axis/client/Call.java @@ -51,6 +51,7 @@ import org.apache.axis.soap.SOAPConstants; import org.apache.axis.transport.http.HTTPTransport; import org.apache.axis.utils.ClassUtils; +import org.apache.axis.utils.IOUtils; import org.apache.axis.utils.JavaUtils; import org.apache.axis.utils.Messages; import org.apache.axis.utils.LockableHashtable; @@ -82,6 +83,8 @@ import java.io.StringWriter; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; @@ -332,17 +335,17 @@ public Call(Service service) { /** * Build a call from a URL string. * - * This is handy so that you don't have to manually call Call.initialize() - * in order to register custom transports. In other words, whereas doing - * a new URL("local:...") would fail, new Call("local:...") works because - * we do the initialization of our own and any configured custom protocols. - * * @param url the target endpoint URL * @exception MalformedURLException */ public Call(String url) throws MalformedURLException { this(new Service()); - setTargetEndpointAddress(new URL(url)); + try { + setTargetEndpointAddress(IOUtils.toURI(url)); + } catch (URISyntaxException ex) { + // The method used to use new URL(...). Need this to ensure source code compatibility: + throw new MalformedURLException(ex.getMessage()); + } } /** @@ -803,31 +806,41 @@ public String getEncodingStyle() { * as URI */ public void setTargetEndpointAddress(String address) { - URL urlAddress; try { - urlAddress = new URL(address); + setTargetEndpointAddress(IOUtils.toURI(address)); } - catch (MalformedURLException mue) { + catch (URISyntaxException mue) { throw new JAXRPCException(mue); } - setTargetEndpointAddress(urlAddress); } /** * Sets the URL of the target Web Service. + *

+ * Note: Not part of JAX-RPC specification. * + * @param address URL of the target Web Service + */ + public void setTargetEndpointAddress(URL address) { + // Note: the URL#toURI method is not available in Java 1.4 + setTargetEndpointAddress(address == null ? null : address.toString()); + } + + /** + * Sets the URL of the target Web Service. + *

* Note: Not part of JAX-RPC specification. * * @param address URL of the target Web Service */ - public void setTargetEndpointAddress(java.net.URL address) { + public void setTargetEndpointAddress(URI address) { try { if ( address == null ) { setTransport(null); return ; } - String protocol = address.getProtocol(); + String protocol = address.getScheme(); // Handle the case where the protocol is the same but we // just want to change the URL - if so just set the URL, @@ -840,8 +853,8 @@ public void setTargetEndpointAddress(java.net.URL address) { if ( this.transport != null ) { String oldAddr = this.transport.getUrl(); if ( oldAddr != null && !oldAddr.equals("") ) { - URL tmpURL = new URL( oldAddr ); - String oldProto = tmpURL.getProtocol(); + URI tmpURL = IOUtils.toURI( oldAddr ); + String oldProto = tmpURL.getScheme(); if ( protocol.equals(oldProto) ) { this.transport.setUrl( address.toString() ); return ; @@ -1623,7 +1636,7 @@ public void setOperation(QName portName, QName opName) { } // we reinitialize target endpoint only if we have wsdl - this.setTargetEndpointAddress( (URL) null ); + this.setTargetEndpointAddress( (URI) null ); Port port = wsdlService.getPort( portName.getLocalPart() ); if ( port == null ) { @@ -1639,8 +1652,7 @@ public void setOperation(QName portName, QName opName) { if ( obj instanceof SOAPAddress ) { try { SOAPAddress addr = (SOAPAddress) obj ; - URL url = new URL(addr.getLocationURI()); - this.setTargetEndpointAddress(url); + this.setTargetEndpointAddress(addr.getLocationURI()); } catch(Exception exp) { throw new JAXRPCException( diff --git a/axis-rt-core/src/main/java/org/apache/axis/client/Service.java b/axis-rt-core/src/main/java/org/apache/axis/client/Service.java index ffdf92f84..0aececafa 100644 --- a/axis-rt-core/src/main/java/org/apache/axis/client/Service.java +++ b/axis-rt-core/src/main/java/org/apache/axis/client/Service.java @@ -47,6 +47,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Proxy; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.rmi.Remote; import java.util.HashMap; @@ -439,7 +440,7 @@ private Remote getPort(String endpoint, QName portName, if (portName == null) { call = (org.apache.axis.client.Call) createCall(); if (endpoint != null) { - call.setTargetEndpointAddress(new URL(endpoint)); + call.setTargetEndpointAddress(endpoint); } } else { call = (org.apache.axis.client.Call) createCall(portName); @@ -494,8 +495,7 @@ public javax.xml.rpc.Call createCall(QName portName) if (obj instanceof SOAPAddress) { try { SOAPAddress addr = (SOAPAddress) obj; - URL url = new URL(addr.getLocationURI()); - call.setTargetEndpointAddress(url); + call.setTargetEndpointAddress(addr.getLocationURI()); } catch (Exception exp) { throw new ServiceException( Messages.getMessage("cantSetURI00", "" + exp)); @@ -871,14 +871,14 @@ public void setHandlerChain(QName portName, List chain) { /** * Register a Transport for a particular URL. */ - void registerTransportForURL(URL url, Transport transport) { + void registerTransportForURL(URI url, Transport transport) { transportImpls.put(url.toString(), transport); } /** * Get any registered Transport object for a given URL. */ - Transport getTransportForURL(URL url) { + Transport getTransportForURL(URI url) { return (Transport) transportImpls.get(url.toString()); } diff --git a/axis-rt-core/src/main/java/org/apache/axis/transport/local/LocalSender.java b/axis-rt-core/src/main/java/org/apache/axis/transport/local/LocalSender.java index 1e9cec04c..26962fbcc 100644 --- a/axis-rt-core/src/main/java/org/apache/axis/transport/local/LocalSender.java +++ b/axis-rt-core/src/main/java/org/apache/axis/transport/local/LocalSender.java @@ -26,10 +26,11 @@ import org.apache.axis.message.SOAPEnvelope; import org.apache.axis.message.SOAPFault; import org.apache.axis.server.AxisServer; +import org.apache.axis.utils.IOUtils; import org.apache.axis.utils.Messages; import org.apache.commons.logging.Log; -import java.net.URL; +import java.net.URI; /** * This is meant to be used on a SOAP Client to call a SOAP server. @@ -114,8 +115,8 @@ public void invoke(MessageContext clientContext) throws AxisFault { String transURL = clientContext.getStrProp(MessageContext.TRANS_URL); if (transURL != null) { try { - URL url = new URL(transURL); - String file = url.getFile(); + URI url = IOUtils.toURI(transURL); + String file = url.getPath(); if (file.length()>0 && file.charAt(0)=='/') { file = file.substring(1); } diff --git a/axis-rt-core/src/main/java/org/apache/axis/utils/DummyURLStreamHandler.java b/axis-rt-core/src/main/java/org/apache/axis/utils/DummyURLStreamHandler.java new file mode 100644 index 000000000..328629e53 --- /dev/null +++ b/axis-rt-core/src/main/java/org/apache/axis/utils/DummyURLStreamHandler.java @@ -0,0 +1,31 @@ +/* + * 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.axis.utils; + +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; + +final class DummyURLStreamHandler extends URLStreamHandler { + static final DummyURLStreamHandler INSTANCE = new DummyURLStreamHandler(); + + protected URLConnection openConnection(URL u) { + throw new UnsupportedOperationException(); + } +} diff --git a/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java b/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java index 411b1f9aa..cb9d77af3 100644 --- a/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java +++ b/axis-rt-core/src/main/java/org/apache/axis/utils/IOUtils.java @@ -18,6 +18,11 @@ import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLStreamHandler; /** * Utility class containing IO helper methods @@ -62,4 +67,41 @@ public static int readFully(InputStream in, byte[] b, int off, int len) } } } + + /** + * Constructs a {@link URI} by parsing the given string. This method basically does the same as + * {@link URI#URI(String)}, with one exception: it accepts URIs of the form + * <scheme>: (e.g. local:). They are accepted by {@link URL}, but they are + * not valid URIs. If the passed string is of that form, the method adds a slash to make it a + * valid URI, i.e. it transforms <scheme>: into <scheme>:/. This ensures + * compatibility with Axis 1.4 (which used {@link URL} internally). + * + * @param str + * the string to be parsed into a URI + * @return the URI + * @throws URISyntaxException + * if the given string is not a valid URI + */ + public static URI toURI(String str) throws URISyntaxException { + if (str.indexOf(':') == str.length() - 1) { + str += '/'; + } + return new URI(str); + } + + /** + * Constructs a {@link URL} by parsing the given string. This method does the same as + * {@link URL#URL(String)}, except that it configures the URL with a dummy + * {@link URLStreamHandler}. This means that the method works for URIs with any protocol, not + * just protocols for which a {@link URLStreamHandler} is registered. + * + * @param str + * the string to be parsed into a URL + * @return the URL + * @throws MalformedURLException + * if the given string is not a valid URL + */ + public static URL toURL(String str) throws MalformedURLException { + return new URL(null, str, DummyURLStreamHandler.INSTANCE); + } } \ No newline at end of file diff --git a/axis-rt-core/src/main/java/org/apache/axis/utils/Options.java b/axis-rt-core/src/main/java/org/apache/axis/utils/Options.java index 7d0f3887e..6789ff183 100644 --- a/axis-rt-core/src/main/java/org/apache/axis/utils/Options.java +++ b/axis-rt-core/src/main/java/org/apache/axis/utils/Options.java @@ -27,6 +27,8 @@ import org.apache.commons.logging.Log; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.Vector; @@ -228,17 +230,18 @@ public String getURL() throws MalformedURLException { String servlet = null ; // -s also -f (file) String protocol = null ; - URL url = null ; + URI url = null ; - // Just in case... - org.apache.axis.client.Call.initialize(); - if ( (tmp = isValueSet( 'l' )) != null ) { - url = new URL( tmp ); + try { + url = IOUtils.toURI( tmp ); + } catch (URISyntaxException ex) { + throw new MalformedURLException(ex.getMessage()); + } host = url.getHost(); port = "" + url.getPort(); - servlet = url.getFile(); - protocol = url.getProtocol(); + servlet = url.getPath(); + protocol = url.getScheme(); } if ( (tmp = isValueSet( 'f' )) != null ) { diff --git a/axis-rt-core/src/test/java/org/apache/axis/utils/IOUtilsTest.java b/axis-rt-core/src/test/java/org/apache/axis/utils/IOUtilsTest.java new file mode 100644 index 000000000..db6cee0cf --- /dev/null +++ b/axis-rt-core/src/test/java/org/apache/axis/utils/IOUtilsTest.java @@ -0,0 +1,38 @@ +/* + * 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.axis.utils; + +import java.net.URI; +import java.net.URL; + +import junit.framework.TestCase; + +public class IOUtilsTest extends TestCase { + public void testToURIParticularCase() throws Exception { + URI uri = IOUtils.toURI("local:"); + assertEquals("local", uri.getScheme()); + assertEquals("/", uri.getPath()); + } + + public void testToURL() throws Exception { + String s = "fancyp://user:password@localhost:8888/dest?prop=value"; + URL url = IOUtils.toURL(s); + assertEquals(s, url.toString()); + } +} diff --git a/samples/jms-sample/src/main/java/samples/jms/dii/JMSURLTest.java b/samples/jms-sample/src/main/java/samples/jms/dii/JMSURLTest.java index 409ba464e..b79f63ce9 100644 --- a/samples/jms-sample/src/main/java/samples/jms/dii/JMSURLTest.java +++ b/samples/jms-sample/src/main/java/samples/jms/dii/JMSURLTest.java @@ -108,8 +108,7 @@ public static Float getQuote(String ticker, String username, String password) try { - java.net.URL jmsurl = new java.net.URL(sampleJmsUrl); - call.setTargetEndpointAddress(jmsurl); + call.setTargetEndpointAddress(sampleJmsUrl); // set additional params on the call if desired call.setUsername(username); @@ -118,10 +117,6 @@ public static Float getQuote(String ticker, String username, String password) res = (Float) call.invoke(new Object[] {ticker}); } - catch (java.net.MalformedURLException e) - { - throw new AxisFault("Invalid JMS URL", e); - } catch (java.rmi.RemoteException e) { throw new AxisFault("Failed in getQuote()", e); diff --git a/samples/jms-sample/src/main/java/samples/jms/stub/JMSURLStubTest.java b/samples/jms-sample/src/main/java/samples/jms/stub/JMSURLStubTest.java index be4402dad..806c6ccfa 100644 --- a/samples/jms-sample/src/main/java/samples/jms/stub/JMSURLStubTest.java +++ b/samples/jms-sample/src/main/java/samples/jms/stub/JMSURLStubTest.java @@ -25,8 +25,6 @@ import junit.framework.AssertionFailedError; import junit.framework.TestCase; -import java.net.MalformedURLException; -import java.net.URL; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; @@ -57,12 +55,10 @@ public static Float getQuote(String endptAddr, String ticker) throws AxisFault { } try { - getQuote = locator.getGetQuote(new URL(endptAddr)); + getQuote = locator.getGetQuote(endptAddr); } catch (ServiceException e) { throw new AxisFault("JAX-RPC ServiceException caught: ", e); - } catch (MalformedURLException e) { - throw new AxisFault("MalformedURLException caught: ", e); } assertTrue("getQuote is null", getQuote != null); diff --git a/samples/transport-sample/src/main/java/samples/transport/tcp/AdminClient.java b/samples/transport-sample/src/main/java/samples/transport/tcp/AdminClient.java index 348c2aa0d..bfc3a451b 100644 --- a/samples/transport-sample/src/main/java/samples/transport/tcp/AdminClient.java +++ b/samples/transport-sample/src/main/java/samples/transport/tcp/AdminClient.java @@ -33,7 +33,6 @@ public class AdminClient extends org.apache.axis.client.AdminClient { public static void main(String args[]) { - Call.addTransportPackage("samples.transport"); Call.setTransportForProtocol("tcp", TCPTransport.class); // Deploy the transport on top of the default client configuration. diff --git a/samples/transport-sample/src/main/java/samples/transport/tcp/GetQuote.java b/samples/transport-sample/src/main/java/samples/transport/tcp/GetQuote.java index 209dc7b47..a5fa397d8 100644 --- a/samples/transport-sample/src/main/java/samples/transport/tcp/GetQuote.java +++ b/samples/transport-sample/src/main/java/samples/transport/tcp/GetQuote.java @@ -28,7 +28,6 @@ import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; -import java.net.URL; /** * @@ -39,7 +38,6 @@ public class GetQuote { // helper function; does all the real work public float getQuote (String args[]) throws Exception { - Call.addTransportPackage("samples.transport"); Call.setTransportForProtocol("tcp", TCPTransport.class); Options opts = new Options( args ); @@ -65,7 +63,7 @@ public float getQuote (String args[]) throws Exception { call.setTransport(new TCPTransport()); - call.setTargetEndpointAddress( new URL(opts.getURL()) ); + call.setTargetEndpointAddress(opts.getURL()); call.setOperationName( new QName("urn:xmltoday-delayed-quotes", "getQuote") ); call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN ); call.setReturnType( XMLType.XSD_FLOAT ); diff --git a/samples/transport-sample/src/main/java/samples/transport/tcp/Handler.java b/samples/transport-sample/src/main/java/samples/transport/tcp/Handler.java deleted file mode 100644 index ad4e6c665..000000000 --- a/samples/transport-sample/src/main/java/samples/transport/tcp/Handler.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed 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 samples.transport.tcp; - -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; - -/** - * A stub URLStreamHandler, so the system will recognize our - * custom URLs as valid. - * - * @author Glen Daniels (gdaniels@apache.org) - */ -public class Handler extends URLStreamHandler -{ - protected URLConnection openConnection(URL u) - { - return null; - } -} diff --git a/samples/transport-sample/src/main/java/samples/transport/tcp/TCPTransport.java b/samples/transport-sample/src/main/java/samples/transport/tcp/TCPTransport.java index b641ff372..384c27828 100644 --- a/samples/transport-sample/src/main/java/samples/transport/tcp/TCPTransport.java +++ b/samples/transport-sample/src/main/java/samples/transport/tcp/TCPTransport.java @@ -17,13 +17,15 @@ package samples.transport.tcp; import org.apache.axis.AxisEngine; +import org.apache.axis.AxisFault; import org.apache.axis.MessageContext; import org.apache.axis.client.Call; import org.apache.axis.client.Transport; import org.apache.axis.components.logger.LogFactory; import org.apache.commons.logging.Log; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; /** * @@ -63,17 +65,17 @@ public TCPTransport (String host, String port) { */ public void setupMessageContextImpl(MessageContext mc, Call call, - AxisEngine engine) + AxisEngine engine) throws AxisFault { try { String urlString = mc.getStrProp(MessageContext.TRANS_URL); if (urlString != null) { - URL url = new URL(urlString); + URI url = new URI(urlString); host = url.getHost(); port = new Integer(url.getPort()).toString(); } - } catch (java.net.MalformedURLException e) { - // Do nothing here? + } catch (URISyntaxException ex) { + throw AxisFault.makeFault(ex); } if (host != null) mc.setProperty(HOST, host); diff --git a/samples/transport-sample/src/test/java/test/functional/TestTCPTransportSample.java b/samples/transport-sample/src/test/java/test/functional/TestTCPTransportSample.java index da7c322e0..0c1acbc36 100644 --- a/samples/transport-sample/src/test/java/test/functional/TestTCPTransportSample.java +++ b/samples/transport-sample/src/test/java/test/functional/TestTCPTransportSample.java @@ -33,7 +33,6 @@ import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; -import java.net.URL; /** Test the stock sample code. */ @@ -74,7 +73,7 @@ public void doTestStock() throws Exception { Call call = (Call) service.createCall(); - call.setTargetEndpointAddress( new URL(uri) ); + call.setTargetEndpointAddress(uri); call.setOperationName( new QName("urn:xmltoday-delayed-quotes", "getQuote") ); call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN ); call.setReturnType( XMLType.XSD_FLOAT );