WSDL2XML generated binding not passing correct method arguments in service 
implementation
-----------------------------------------------------------------------------------------

                 Key: CXF-2228
                 URL: https://issues.apache.org/jira/browse/CXF-2228
             Project: CXF
          Issue Type: Bug
    Affects Versions: 2.1.5, 2.1.3
         Environment: Test Service is deployed in Tomcat (6.0.14) Using Java 
build (1.6.0_06-b020) 
            Reporter: Vinod D


http://www.nabble.com/wsdl2xml-and-XML-Binding-td23608106.html

Hello 

I am running into an isse with XML Binding. Here is what I am doing 

- Using CXF 2.1.3 and deploying it in tomcat 6.x 
- Define a simple wsdl (wsdl first approach) with one method (sayHi) which 
takes two string params and returns a cat-ed string. 
- Works fine using SOAP Binding (first two log entried below). 
- Used wsdl2xml tool to create a XML Port and XML Binding and invoke the sayHi 
method. 
- I see in XML message logging on tomcat call (sayHi) coming with two string 
param , however to the service method impl I see both the strings 
are passed as null (last two log-entry below). 

Are there any issues re. using wsdl2xml in this manner or something I am 
missing. 

regards 
-Vinod 

---------------------------------- 
INFO: Inbound Message 
---------------------------- 
Payload: <soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>< 
soap:Body><ns2:sayHi 
xmlns:ns2="http://acme.com/test/";><arg1>argument1</arg1><ar 
g2>argument2</arg2></ns2:sayHi></soap:Body></soap:Envelope> 
-------------------------------------- 
TestPortTypeImpl::sayHi() is called arg1=argument1, arg2=argument2 
May 18, 2009 4:42:25 PM 
org.apache.cxf.interceptor.LoggingOutInterceptor$Logging 
Callback onClose 
INFO: Outbound Message 
--------------------------- 
Payload: <soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>< 
soap:Body><ns2:sayHiResponse xmlns:ns2="http://acme.com/test/";><out>sayHi to : 
a 
rgument1 and argument2</out></ns2:sayHiResponse></soap:Body></soap:Envelope> 
-------------------------------------- 
INFO: Inbound Message 
---------------------------- 
Payload: <ns2:sayHi 
xmlns:ns2="http://acme.com/test/";><arg1>argument1</arg1><arg 
2>argument2</arg2></ns2:sayHi> 
-------------------------------------- 
TestPortTypeXMLImpl::sayHi() is called arg1=null, arg2=null 
May 18, 2009 4:47:55 PM 
org.apache.cxf.interceptor.LoggingOutInterceptor$Logging 
Callback onClose 
INFO: Outbound Message 
--------------------------- 
Encoding: UTF-8 
Headers: {} 
Messages: 
Payload: <ns2:sayHiResponse xmlns:ns2="http://acme.com/test/";><out>sayHi to : 
nu 
ll and null</out></ns2:sayHiResponse> 
-------------------------------------- 

Some more obervation: 

If I comment out the <xformat:body ...rootNode="sayHi"> element from the XML 
binding generated by wsdl2xml as shown below, I see the parameters passed 
correctly to the service implementation and works as expected. 

<wsdl:bindingname="testXMLBinding"type="tns:testPortType"><xformat:binding/><wsdl:operationname="sayHi"><wsdl:input><!--
 xformat:body xmlns="http://acme.com/test/"; rootNode="sayHi" / 
--></wsdl:input><wsdl:output><!-- xformat:body xmlns="http://acme.com/test/"; 
rootNode="sayHi" / --></wsdl:output></wsdl:operation></wsdl:binding> 

Not sure what is right approach here .. 

-Vinod  

Re: wsdl2xml and XML Binding  by dkulp May 19, 2009; 01:24pm :: Rate this 
Message:    - Use ratings to moderate (?)

Reply | Reply to Author | Print | View Threaded | Show Only this Message 

That SHOULD be fine.   Can you : 

1) try with CXF 2.1.5 or 2.2.1.   This MAY be fixed already. 

2) If not, can you package up your sample and attach it to a JIRA bug report? 

Thanks! 
Dan 
 
- I tried using 2.1.5 and still observed the same issue. Test  Wsdl which has 
xml binding generated from WSDL2XML and client/server are pasted below.

WSDL 
_____
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="test" targetNamespace="http://acme.com/test/"; 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"; 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:tns="http://acme.com/test/"; 
xmlns:xformat="http://cxf.apache.org/bindings/xformat"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";>
  <wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="http://acme.com/test/";>
            <xsd:element name="sayHi">
                <xsd:complexType>
                        <xsd:sequence>

                                <xsd:element name="arg1" type="xsd:string"/>
                                <xsd:element name="arg2" type="xsd:string">
                                </xsd:element>
                        </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="sayHiResponse">
                <xsd:complexType>
                        <xsd:sequence>

                                <xsd:element name="out" type="xsd:string"/>
                        </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
  </wsdl:types>
  <wsdl:message name="sayHiRequest">
    <wsdl:part name="in" element="tns:sayHi">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="sayHiResponse">
    <wsdl:part name="out" element="tns:sayHiResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="testPortType">
    <wsdl:operation name="sayHi">
      <wsdl:input message="tns:sayHiRequest">
    </wsdl:input>
      <wsdl:output message="tns:sayHiResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="testSOAP" type="tns:testPortType">
    <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sayHi">
      <soap:operation soapAction="http://acme.com/test/sayHi"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="testXMLBinding" type="tns:testPortType">
    <xformat:binding />
    <wsdl:operation name="sayHi">
      <wsdl:input>
      <xformat:body xmlns="http://acme.com/test/"; rootNode="sayHi" />
      </wsdl:input>
      <wsdl:output>
      <xformat:body xmlns="http://acme.com/test/"; rootNode="sayHi" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="test">
    <wsdl:port name="testXMLPort" binding="tns:testXMLBinding">
      <http:address location="http://localhost:8080/test/services/testxml"; />
    </wsdl:port>
    <wsdl:port name="testSOAP" binding="tns:testSOAP">
      <soap:address location="http://localhost:8080/test/services/test"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Service 
______
TestPortTypeImpl.java and TestPortTypeXMLImpl.java are below

package com.acme.server;

import javax.jws.WebService;

import com.acme.test.TestPortType;

/**
 *
 */
@WebService(targetNamespace = "http://acme.com/test/";,
            portName="testXMLPort",
            serviceName="test",
            endpointInterface="com.acme.test.TestPortType")

public class TestPortTypeXMLImpl implements TestPortType {

        /*
         * (non-Javadoc)
         * 
         * @see com.acme.test.TestPortType#sayHi(java.lang.String, 
java.lang.String)
         */
        public String sayHi(String arg1, String arg2) {
                System.out.println("TestPortTypeXMLImpl::sayHi() is called 
arg1="
                                + arg1 + ", arg2=" + arg2);
                return "sayHi to : " + arg1 + " and " + arg2;
        }
}

package com.acme.server;

import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;

import com.acme.test.ObjectFactory;
import com.acme.test.TestPortType;

/**
 * Some test program
 */
@WebService(targetNamespace = "http://acme.com/test/";,
                    portName="testSOAP",
                    serviceName="test",
                    endpointInterface="com.acme.test.TestPortType")
@XmlSeeAlso({ObjectFactory.class})

public class TestPortTypeImpl implements TestPortType {

        /* (non-Javadoc)
         * @see com.acme.test.TestPortType#sayHi(java.lang.String, 
java.lang.String)
         */
        public String sayHi(String arg1, String arg2) {
                System.out.println("TestPortTypeImpl::sayHi() is called arg1=" 
+ arg1 + 
                                           ", arg2=" + arg2 );
                return "sayHi to : " + arg1 + " and "  + arg2;
        }
}


Client Test Program
________________
package com.acme.client;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.namespace.QName;

import com.acme.test.Test;
import com.acme.test.TestPortType;

/**
 *
 */
public class TestClient {

    public final static URL WSDL_LOCATION;
    public final static QName SERVICE = new QName("http://acme.com/test/";, 
"test");
    public final static QName TestSoapPort = new QName("http://acme.com/test/";, 
"TestSOAP");
    public final static QName TestXMLPort = new QName("http://acme.com/test/";, 
"TestXMLPort");
        
        Test m_testService = null;      
        TestPortType m_portType = null;
    
    static {
        URL url = null;
        try {
            url = new URL("http://localhost:8080/acws/services/test?wsdl";);
        } catch (MalformedURLException e) {
            System.err.println("Can not initialize the default wsdl from 
file:/C:/acme/nbi/cpsm/build/../nbi/wsdl/acws.wsdl");
            // e.printStackTrace();
        }
        WSDL_LOCATION = url;
    }
        
        /**
         * @param args
         */
        public static void main(String[] args) {
                TestClient client = new TestClient();
                client.initializeService(args);
                client.testHi(args);
        }
        
        private void testHi(String[] args) {
                try {
                   String result = m_portType.sayHi("argument1", "argument2");
                   System.out.println("Called sayHi() and got =" + result);
                }catch (Exception e) {
                        e.printStackTrace();
                }
        }

        private void initializeService(String [] args) {
                
                try {
                        m_testService = new Test(WSDL_LOCATION, SERVICE);
                        m_portType = m_testService.getTestXMLPort();
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}

Please refer to the thread on this -> 
http://www.nabble.com/wsdl2xml-and-XML-Binding-td23608106.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to