You add xml is not a pull json file.
It has some xml tags, you need to clean it up.
On 8/24/11 3:21 PM, yyc178 wrote:
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/WHY-who-can-help-me-tp4729519p4729519.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang