cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Mao <james....@iona.com>
Subject Re: svn commit: r504289 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/ testutils/ testutils/src/main/java/org/apache/header_test/rpc/ testutils/src/main/resources/wsdl/ tools/wsdl2java/src/main/java/org/apache/cxf/t...
Date Wed, 07 Feb 2007 04:03:30 GMT
This fix should also into tools2.
If there is bug in code gen, please fix into tools2 directly, almost all 
the code has been ported to tools2
I'll reopen the CXF-261 to do the fix in tools2.

Cheers,
James.
> Author: dkulp
> Date: Tue Feb  6 12:56:15 2007
> New Revision: 504289
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=504289
> Log:
> Testcase for CXF-261
>
> * CXF-261 is no longer applicable, but nothing tests it.   Added a rcp/literal soap header
test
> * That said, the code generator was broken for rpc/literal with headers (headers are
always doc/literal).  Fixed that and added a test in testutils to check to makre sure the
generated code is correct.
>
>
> Added:
>     incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/rpc/
>     incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/rpc/TestRPCHeaderImpl.java
  (with props)
>     incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader_rpc.wsdl   (with
props)
> Modified:
>     incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
>     incubator/cxf/trunk/testutils/pom.xml
>     incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ParameterProcessor.java
>     incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java
>
> Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java?view=diff&rev=504289&r1=504288&r2=504289
> ==============================================================================
> --- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
(original)
> +++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
Tue Feb  6 12:56:15 2007
> @@ -36,6 +36,10 @@
>  import org.apache.header_test.SOAPHeaderService;
>  import org.apache.header_test.TestHeader;
>  import org.apache.header_test.TestHeaderImpl;
> +import org.apache.header_test.rpc.SOAPRPCHeaderService;
> +import org.apache.header_test.rpc.TestRPCHeader;
> +import org.apache.header_test.rpc.TestRPCHeaderImpl;
> +import org.apache.header_test.rpc.types.HeaderMessage;
>  import org.apache.header_test.types.TestHeader1;
>  import org.apache.header_test.types.TestHeader1Response;
>  import org.apache.header_test.types.TestHeader2;
> @@ -54,27 +58,31 @@
>      private final QName portName = new QName("http://apache.org/header_test",
>                                               "SoapHeaderPort");
>  
> -    private TestHeader proxy;
> -    
>      public void setUp() throws Exception {
>          super.setUp();
>          BusFactory.setDefaultBus(getBus());
>          
>          Object implementor = new TestHeaderImpl();
>          String address = "http://localhost:9104/SoapHeaderContext/SoapHeaderPort";
> -        EndpointImpl e = (EndpointImpl) Endpoint.publish(address, implementor);
> +        EndpointImpl e = (EndpointImpl) Endpoint.publish(address, implementor);    
   
> +        e.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
> +        e.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
>          
> +        implementor = new TestRPCHeaderImpl();
> +        address = "http://localhost:9104/SoapHeaderRPCContext/SoapHeaderRPCPort";
> +        e = (EndpointImpl)Endpoint.publish(address, implementor);        
>          e.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
>          e.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
> +        
>      }
> -    
> +
>      public void testInHeader() throws Exception {
>          URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
>          assertNotNull(wsdl);
>          
>          SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
>          assertNotNull(service);
> -        proxy = service.getPort(portName, TestHeader.class);
> +        TestHeader proxy = service.getPort(portName, TestHeader.class);
>          try {
>              TestHeader1 val = new TestHeader1();
>              for (int idx = 0; idx < 2; idx++) {
> @@ -93,7 +101,7 @@
>          
>          SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
>          assertNotNull(service);
> -        proxy = service.getPort(portName, TestHeader.class);
> +        TestHeader proxy = service.getPort(portName, TestHeader.class);
>          try {
>              TestHeader2 in = new TestHeader2();
>              String val = new String(TestHeader2Response.class.getSimpleName());
> @@ -119,7 +127,7 @@
>          
>          SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
>          assertNotNull(service);
> -        proxy = service.getPort(portName, TestHeader.class);
> +        TestHeader proxy = service.getPort(portName, TestHeader.class);
>          
>          try {
>              TestHeader3 in = new TestHeader3();
> @@ -154,7 +162,7 @@
>          
>          SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
>          assertNotNull(service);
> -        proxy = service.getPort(portName, TestHeader.class);
> +        TestHeader proxy = service.getPort(portName, TestHeader.class);
>          try {
>              TestHeader5 in = new TestHeader5();
>              String val = new String(TestHeader5.class.getSimpleName());
> @@ -178,7 +186,7 @@
>          
>          SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
>          assertNotNull(service);
> -        proxy = service.getPort(portName, TestHeader.class);
> +        TestHeader proxy = service.getPort(portName, TestHeader.class);
>      
>          TestHeader6 in = new TestHeader6();
>          String val = new String(TestHeader6.class.getSimpleName());
> @@ -209,7 +217,7 @@
>          
>          SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
>          assertNotNull(service);
> -        proxy = service.getPort(portName, TestHeader.class);
> +        TestHeader proxy = service.getPort(portName, TestHeader.class);
>          try {
>              proxy.testHeader4("cxf");
>          } catch (Exception e) {
> @@ -218,6 +226,56 @@
>          }
>      }
>  
> +    public void testRPCInHeader() throws Exception {
> +        URL wsdl = getClass().getResource("/wsdl/soapheader_rpc.wsdl");
> +        assertNotNull(wsdl);
> +        
> +        SOAPRPCHeaderService service
> +            = new SOAPRPCHeaderService(wsdl, 
> +                new QName("http://apache.org/header_test/rpc", "SOAPRPCHeaderService"));
> +        assertNotNull(service);
> +        TestRPCHeader proxy = service.getSoapRPCHeaderPort();
> +        try { 
> +            HeaderMessage header = new HeaderMessage();
> +            header.setHeaderVal("header");
> +            
> +            for (int idx = 0; idx < 2; idx++) {
> +                String returnVal = proxy.testHeader1("part", header);
> +                assertNotNull(returnVal);
> +                assertEquals("part/header", returnVal);
> +            }
> +        } catch (UndeclaredThrowableException ex) {
> +            throw (Exception)ex.getCause();
> +        }
> +    } 
> +    
> +    public void testRPCInOutHeader() throws Exception {
> +        URL wsdl = getClass().getResource("/wsdl/soapheader_rpc.wsdl");
> +        assertNotNull(wsdl);
> +        
> +        SOAPRPCHeaderService service
> +            = new SOAPRPCHeaderService(wsdl, 
> +                new QName("http://apache.org/header_test/rpc", "SOAPRPCHeaderService"));
> +        assertNotNull(service);
> +        TestRPCHeader proxy = service.getSoapRPCHeaderPort();
> +        try { 
> +            HeaderMessage header = new HeaderMessage();
> +            Holder<HeaderMessage> holder = new Holder<HeaderMessage>(header);
> +            
> +            for (int idx = 0; idx < 2; idx++) {
> +                holder.value.setHeaderVal("header" + idx);
> +                String returnVal = proxy.testInOutHeader("part" + idx, holder);
> +                
> +                assertNotNull(returnVal);
> +                assertEquals("header" + idx, returnVal);
> +                assertEquals("part" + idx, holder.value.getHeaderVal());
> +            }
> +        } catch (UndeclaredThrowableException ex) {
> +            throw (Exception)ex.getCause();
> +        }
> +    } 
> +    
> +    
>      public static void main(String[] args) {
>          junit.textui.TestRunner.run(HeaderClientServerTest.class);
>      }
>
> Modified: incubator/cxf/trunk/testutils/pom.xml
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/pom.xml?view=diff&rev=504289&r1=504288&r2=504289
> ==============================================================================
> --- incubator/cxf/trunk/testutils/pom.xml (original)
> +++ incubator/cxf/trunk/testutils/pom.xml Tue Feb  6 12:56:15 2007
> @@ -244,6 +244,9 @@
>                                      <wsdl>${basedir}/src/main/resources/wsdl/soapheader2.wsdl</wsdl>
>                                  </wsdlOption>
>                                  <wsdlOption>
> +                                    <wsdl>${basedir}/src/main/resources/wsdl/soapheader_rpc.wsdl</wsdl>
> +                                </wsdlOption>
> +                                <wsdlOption>
>                                      <wsdl>${basedir}/src/main/resources/wsdl/locator.wsdl</wsdl>
>                                      <extraargs>
>                                          <extraarg>-p</extraarg>
>
> Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/rpc/TestRPCHeaderImpl.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/rpc/TestRPCHeaderImpl.java?view=auto&rev=504289
> ==============================================================================
> --- incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/rpc/TestRPCHeaderImpl.java
(added)
> +++ incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/rpc/TestRPCHeaderImpl.java
Tue Feb  6 12:56:15 2007
> @@ -0,0 +1,48 @@
> +/**
> + * 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.header_test.rpc;
> +
> +import javax.jws.WebService;
> +import javax.xml.ws.Holder;
> +
> +import org.apache.header_test.rpc.types.HeaderMessage;
> +
> +
> +@WebService(serviceName = "SOAPRPCHeaderService", 
> +            portName = "SoapRPCHeaderPort", 
> +            endpointInterface = "org.apache.header_test.rpc.TestRPCHeader",
> +            targetNamespace = "http://apache.org/header_test/rpc")
> +            
> +public class TestRPCHeaderImpl implements TestRPCHeader {
> +
> +    public String testHeader1(String in, HeaderMessage inHeader) {
> +        if (in == null || inHeader == null) {
> +            throw new IllegalArgumentException("TestHeader1 part not found.");
> +        }
> +        
> +        return in + "/" + inHeader.getHeaderVal();
> +    }
> +
> +    public String testInOutHeader(String in, Holder<HeaderMessage> inOutHeader)
{
> +        String tmp = inOutHeader.value.getHeaderVal();
> +        inOutHeader.value.setHeaderVal(in);
> +        return tmp;
> +    }
> +
> +}
>
> Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/rpc/TestRPCHeaderImpl.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/header_test/rpc/TestRPCHeaderImpl.java
> ------------------------------------------------------------------------------
>     svn:keywords = Rev Date
>
> Added: incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader_rpc.wsdl
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader_rpc.wsdl?view=auto&rev=504289
> ==============================================================================
> --- incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader_rpc.wsdl (added)
> +++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader_rpc.wsdl Tue Feb
 6 12:56:15 2007
> @@ -0,0 +1,88 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> +  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.
> +-->
> +<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://apache.org/header_test/rpc" xmlns:x1="http://apache.org/header_test/rpc/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://apache.org/header_test/rpc" name="TestHeaderWSDL">
> +    <wsdl:types>
> +        <schema targetNamespace="http://apache.org/header_test/rpc/types" xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:x1="http://apache.org/header_test/rpc/types" elementFormDefault="qualified">
> +            <element name="headerMessage">
> +                <complexType>
> +		    <sequence>
> +                        <element name="headerVal" type="string"/>
> +		    </sequence>
> +		</complexType>
> +            </element>
> +        </schema>
> +    </wsdl:types>
> +    <wsdl:message name="testHeader1Request">
> +        <wsdl:part name="in" type="xsd:string"/>
> +        <wsdl:part name="inHeader" element="x1:headerMessage"/>
> +    </wsdl:message>
> +    <wsdl:message name="testHeader1Response">
> +        <wsdl:part name="out" type="xsd:string"/>
> +    </wsdl:message>
> +
> +    <wsdl:message name="testInOutHeaderRequest">
> +        <wsdl:part name="in" type="xsd:string"/>
> +        <wsdl:part name="inOutHeader" element="x1:headerMessage"/>
> +    </wsdl:message>
> +    <wsdl:message name="testInOutHeaderResponse">
> +        <wsdl:part name="out" type="xsd:string"/>
> +        <wsdl:part name="inOutHeader" element="x1:headerMessage"/>
> +    </wsdl:message>
> +
> +    <wsdl:portType name="TestRPCHeader">
> +        <wsdl:operation name="testHeader1">
> +            <wsdl:input name="testHeader1Request" message="tns:testHeader1Request"/>
> +            <wsdl:output name="testHeader1Response" message="tns:testHeader1Response"/>
> +        </wsdl:operation>
> +        <wsdl:operation name="testInOutHeader">
> +            <wsdl:input name="testInOutHeaderRequest" message="tns:testInOutHeaderRequest"/>
> +            <wsdl:output name="testInOutHeaderResponse" message="tns:testInOutHeaderResponse"/>
> +        </wsdl:operation>
> +    </wsdl:portType>
> +    <wsdl:binding name="TestHeader_SOAPRPCBinding" type="tns:TestRPCHeader">
> +        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
> +        <wsdl:operation name="testHeader1">
> +            <soap:operation/>
> +            <wsdl:input name="testHeader1Request">
> +                <soap:body message="tns:testHeader1Request" parts="in" use="literal"
namespace="http://apache.org/header_test"/>
> +                <soap:header message="tns:testHeader1Request" part="inHeader" use="literal"/>
> +            </wsdl:input>
> +            <wsdl:output name="testHeader1Response">
> +                <soap:body message="tns:testHeader1Response" use="literal" namespace="http://apache.org/header_test"/>
> +            </wsdl:output>
> +        </wsdl:operation>
> +        <wsdl:operation name="testInOutHeader">
> +            <soap:operation/>
> +            <wsdl:input>
> +                <soap:body message="tns:testInOutHeaderRequest" parts="in" use="literal"
namespace="http://apache.org/header_test"/>
> +                <soap:header message="tns:testInOutHeaderRequest" part="inOutHeader"
use="literal"/>
> +            </wsdl:input>
> +            <wsdl:output>
> +                <soap:body message="tns:testInOutHeaderResponse" parts="out" use="literal"
namespace="http://apache.org/header_test"/>
> +                <soap:header message="tns:testInOutHeaderRequest" part="inOutHeader"
use="literal"/>
> +            </wsdl:output>
> +        </wsdl:operation>
> +    </wsdl:binding>
> +    <wsdl:service name="SOAPRPCHeaderService">
> +        <wsdl:port name="SoapRPCHeaderPort" binding="tns:TestHeader_SOAPRPCBinding">
> +            <soap:address location="http://localhost:9104/SoapHeaderRPCContext/SoapHeaderRPCPort"/>
> +        </wsdl:port>
> +    </wsdl:service>
> +</wsdl:definitions>
>
> Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader_rpc.wsdl
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader_rpc.wsdl
> ------------------------------------------------------------------------------
>     svn:keywords = Rev Date
>
> Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader_rpc.wsdl
> ------------------------------------------------------------------------------
>     svn:mime-type = text/xml
>
> Modified: incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ParameterProcessor.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ParameterProcessor.java?view=diff&rev=504289&r1=504288&r2=504289
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ParameterProcessor.java
(original)
> +++ incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ParameterProcessor.java
Tue Feb  6 12:56:15 2007
> @@ -129,7 +129,9 @@
>          String targetNamespace = method.getInterface().getNamespace();
>          String partName = null;
>  
> -        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
> +        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT
> +            || parameter.isHeader()) {
> +            //headers are always DOCUMENT style
>              targetNamespace = parameter.getTargetNamespace();
>              if (parameter.getQName() != null) {
>                  name = parameter.getQName().getLocalPart();
> @@ -151,7 +153,8 @@
>              webParamAnnotation.addArgument("mode", "Mode." + parameter.getStyle().toString(),
"");
>          }
>          webParamAnnotation.addArgument("name", name);
> -        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT) {
> +        if (method.getSoapStyle() == SOAPBinding.Style.DOCUMENT
> +            || parameter.isHeader()) {
>              webParamAnnotation.addArgument("targetNamespace", targetNamespace);
>          }
>  
>
> Modified: incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java?view=diff&rev=504289&r1=504288&r2=504289
> ==============================================================================
> --- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java
(original)
> +++ incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/internal/ServiceProcessor.java
Tue Feb  6 12:56:15 2007
> @@ -300,6 +300,8 @@
>      private void setParameterAsHeader(JavaParameter parameter) {
>          parameter.setHeader(true);
>          parameter.getAnnotation().addArgument("header", "true", "");
> +        parameter.getAnnotation().addArgument("name", parameter.getQName().getLocalPart());
> +        parameter.getAnnotation().addArgument("targetNamespace", parameter.getTargetNamespace());
>      }
>  
>      private void processParameter(JavaMethod jm, BindingOperation operation) throws
ToolException {
>
>
>
>   


Mime
View raw message