Home » geronimo-2.2-source-release » org.apache.geronimo.axis » [javadoc | source]

    1   /*
    2    * Copyright 2001-2004 The Apache Software Foundation.
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
   10    * Unless required by applicable law or agreed to in writing, software
   11    * distributed under the License is distributed on an "AS IS" BASIS,
   12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13    * See the License for the specific language governing permissions and
   14    * limitations under the License.
   15    */
   16   package org.apache.geronimo.axis;
   17   
   18   import java.io.InputStream;
   19   import java.net.URI;
   20   import java.util.Collections;
   21   import java.util.HashMap;
   22   import java.util.Map;
   23   import javax.xml.namespace.QName;
   24   
   25   import org.apache.axis.constants.Style;
   26   import org.apache.axis.constants.Use;
   27   import org.apache.axis.description.JavaServiceDesc;
   28   import org.apache.axis.description.OperationDesc;
   29   import org.apache.axis.description.ParameterDesc;
   30   import org.apache.axis.encoding.TypeMapping;
   31   import org.apache.axis.encoding.TypeMappingRegistryImpl;
   32   import org.apache.axis.handlers.soap.SOAPService;
   33   import org.apache.axis.providers.java.RPCProvider;
   34   import org.apache.geronimo.axis.server.AxisWebServiceContainer;
   35   import org.apache.geronimo.axis.server.POJOProvider;
   36   import org.apache.geronimo.axis.server.ReadOnlyServiceDesc;
   37   import org.apache.geronimo.axis.testData.echosample.EchoBean;
   38   import org.apache.geronimo.webservices.WebServiceContainer;
   39   
   40   //import org.openejb.deployment.OpenEJBModuleBuilder;
   41   
   42   /**
   43    *
   44    * @version $Rev: $ $Date: $
   45    */
   46   public class AxisWebServiceContainerTest extends AbstractTestCase {
   47       public AxisWebServiceContainerTest(String testName) {
   48           super(testName);
   49       }
   50   
   51       public void testInvokeSOAP() throws Exception {
   52   
   53           ClassLoader cl = Thread.currentThread().getContextClassLoader();
   54           JavaServiceDesc serviceDesc = new JavaServiceDesc();
   55           serviceDesc.setEndpointURL("http://127.0.0.1:8080/axis/services/echo");
   56           //serviceDesc.setWSDLFile(portInfo.getWsdlURL().toExternalForm());
   57           serviceDesc.setStyle(Style.RPC);
   58           serviceDesc.setUse(Use.ENCODED);
   59   
   60           TypeMappingRegistryImpl tmr = new TypeMappingRegistryImpl();
   61           tmr.doRegisterFromVersion("1.3");
   62           TypeMapping typeMapping = tmr.getOrMakeTypeMapping(serviceDesc.getUse().getEncoding());
   63   
   64           serviceDesc.setTypeMappingRegistry(tmr);
   65           serviceDesc.setTypeMapping(typeMapping);
   66   
   67           OperationDesc op = new OperationDesc();
   68           op.setName("echoString");
   69           op.setStyle(Style.RPC);
   70           op.setUse(Use.ENCODED);
   71           Class beanClass = EchoBean.class;
   72           op.setMethod(beanClass.getMethod("echoString", new Class[] { String.class }));
   73           ParameterDesc parameter =
   74               new ParameterDesc(
   75                   new QName("http://ws.apache.org/echosample", "in0"),
   76                   ParameterDesc.IN,
   77                   typeMapping.getTypeQName(String.class),
   78                   String.class,
   79                   false,
   80                   false);
   81           op.addParameter(parameter);
   82           serviceDesc.addOperationDesc(op);
   83   
   84           serviceDesc.getOperations();
   85           ReadOnlyServiceDesc sd = new ReadOnlyServiceDesc(serviceDesc, Collections.EMPTY_LIST);
   86   
   87           Class pojoClass = cl.loadClass("org.apache.geronimo.axis.testData.echosample.EchoBean");
   88   
   89           RPCProvider provider = new POJOProvider();
   90           SOAPService service = new SOAPService(null, provider, null);
   91           service.setServiceDescription(sd);
   92           service.setOption("className","org.apache.geronimo.axis.testData.echosample.EchoBean");
   93           URI wsdlURL = new URI("echo.wsdl");
   94           URI location = new URI(serviceDesc.getEndpointURL());
   95           Map wsdlMap = new HashMap();
   96   
   97           AxisWebServiceContainer continaer =
   98               new AxisWebServiceContainer(location, wsdlURL, service, wsdlMap, cl);
   99   
  100           InputStream in = cl.getResourceAsStream("echoString-req.txt");
  101   
  102           AxisRequest req =
  103               new AxisRequest(
  104                   504,
  105                   "text/xml; charset=utf-8",
  106                   in,
  107                   0,
  108                   new HashMap(),
  109                   location,
  110                   new HashMap());
  111           AxisResponse res =
  112               new AxisResponse("text/xml; charset=utf-8", "127.0.0.1", null, null, 8080, System.out);
  113   
  114           req.setAttribute(WebServiceContainer.POJO_INSTANCE, pojoClass.newInstance());
  115           continaer.invoke(req, res);
  116           System.out.flush();
  117       }
  118   
  119       protected void setUp() throws Exception {
  120       }
  121   
  122       protected void tearDown() throws Exception {
  123       }
  124   
  125   }

Home » geronimo-2.2-source-release » org.apache.geronimo.axis » [javadoc | source]