Tim:

I would strongly suggest you try doing the code generation using
wsdl2java; your code should work then. If that's true, then you can try
narrowing the issues. You don't necessarily have to continue to use the
generated code (though I do so) but it should help you center in on the
problems.

David Sills


-----Original Message-----
From: Tim [mailto:s...@mail.ru] 
Sent: Friday, September 30, 2011 12:50 AM
To: users@cxf.apache.org
Subject: RE: Non CFX clients for CFX web services

David Sills, thank you for your answer.

No. I don't generate client from wsdl. I don't use wsdl at all.

For better understanding the problem here is client code.
*Axis client*
-----------------------
package com.na.clients;

import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.jdom.JDOMException;

public class AxisClient {

        private static String URL="http://localhost:8080/";;
        private static String SERVICE="trainCFX/HelloWorld";
        private static String METHOD="sayHi";
        
        public Call getCall(String strEndpoint, String strNamespace,
String
strMetodName) throws MalformedURLException
        {
                Service  svcService = new Service();
                Call clCall = null;
                try {clCall = (Call)svcService.createCall();}
                catch (ServiceException e) {e.printStackTrace();}
                clCall.setTargetEndpointAddress( new
java.net.URL(strEndpoint) );
                clCall.setOperationName(new QName(strNamespace,
strMetodName));
                return clCall;
        }
        
        public static void main(String[] args) throws JDOMException {
                AxisClient ac=new AxisClient();         
                Call clCall = null;
                
                try 
                {
                        clCall = ac.getCall(URL+SERVICE,
"http://na.com/";, METHOD);                      
                }               
                catch (IOException e) {
                        e.printStackTrace();
                }
                
                String strResponse="";
                
                try {
                        * //pass param "Tim"  *
                        *strResponse = (String)clCall.invoke(new
Object[] {"Tim"} );*
                } catch (RemoteException e) {
                        e.printStackTrace();
                }
                *System.out.println(strResponse);*              
        }

}
-------------------

*CXF client *(it's the simple client from CXF examples)
--------------
package com.na.clients;

import
org.springframework.context.support.ClassPathXmlApplicationContext;

public class CFXClient {

         private CFXClient() {
            }

            public static void main(String args[]) throws Exception {
                System.out.println("--");
                // START SNIPPET: client
                ClassPathXmlApplicationContext context 
                    = new ClassPathXmlApplicationContext(new String[]
{"com/na/clients/client-beans.xml"});

                HelloWorld client =
(HelloWorld)context.getBean("client");

                * //pass param "Tim"  *
                *String response = client.sayHi("Tim");*
                *System.out.println("Response: " + response);*
                System.exit(0);
                // END SNIPPET: client
            }

}
-----------
*client-bean.xml (for spring)*

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:jaxws="http://cxf.apache.org/jaxws";
        xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd";>

    <bean id="client" class="com.na.clients.HelloWorld" 
      factory-bean="clientFactory" factory-method="create"/>
    
        <bean id="clientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
          <property name="serviceClass"
value="com.na.clients.HelloWorld"/>
          <property name="address"
value="http://localhost:8080/trainCFX/HelloWorld"/>
        </bean>
          
</beans>


*And the difference beteen clients*

Axis print: "hi null"
cxf print: "Response: hi, Tim"


--
View this message in context:
http://cxf.547215.n5.nabble.com/Non-CXF-clients-for-CXF-web-services-tp4
851892p4855793.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to