You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by yyc178 <yy...@yahoo.com.cn> on 2011/08/24 09:44:56 UTC
CXF POST REST parameter is null , help me!
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.