cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yyc178 <yyc...@yahoo.com.cn>
Subject CXF POST REST parameter is null , help me!
Date Wed, 24 Aug 2011 07:44:56 GMT
interface : 

@WebService 
public interface UserManager { 
  

     @Post 
     @HttpResource(location="/saveUserByPost") 
     @Produces("application/json"); 
     public void saveUserByPost(MsUser user) throws WSAPIException; 
} 

impl: 

@WebService(endpointInterface="com.wsapi.user.UserManager") 
public class UserManagerImpl implements UserManager { 

     public void saveUserByPost(MsUser user) throws WSAPIException { 
           System.out.println("user is " + user); 
     } 
} 

client: 
public static void main(String[] argv) { 

   PostMethod post = new
PostMethod("http://localhost:8080/unipf/ws/saveUserByPost"); 
   try { 
       File input = new File("d:\\add.xml"); 
       post.addRequestHeader("Accept", "application/json"); 
       RequestEntity entity = new FileRequestEntity(input,
"application/json"); 
       post.setRequestEntitiy(entity); 
       HttpClient client = new HttpClient(); 
       client.executeMethod(post); 
    } catch (Exception) { 
    } finally { 
       post.releaseConnection(); 
    } 
} 

add.xml: 
<?xml version="1.0" encoding="UTF-8"?> 
<saveUserByPost xmlns="http://user.wsapi.com/">
    {"id":"123","userName":"mmok"} 
</saveUserByPost>


run client and get info: 

     user is null 


why ?  please help me, thanks! 

--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-POST-REST-parameter-is-null-help-me-tp4729564p4729564.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Mime
View raw message