Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.sun.jersey.api.client.*;
- ...
- ClientConfig clientConfig = new DefaultClientConfig();
- Client client = Client.create(clientConfig);
- WebResource webResource = client.resource("https://hj.yahooapis.com/v1/HJAuthTokens");
- webResource.accept("application/xml");
- // body is a hard-coded string, with replacements for the variable bits
- String response = webResource.post(String.class, body);
- // parse response into a org.w3c.dom.Document
- // interface with Document via XPATH, or write my own POJO mappings
- <?xml version="1.0" encoding="utf-8"?>
- <Response>
- <ResponseCode>0</ResponseCode>
- <ResponseMessage>Login successful</ResponseMessage>
- <Token>NTlEMTdFNjk3Qjg4NUJBNDA3MkJFOTI3NzJEMTdDNDU7bG9jYWxob3N0LmVnbGJwLmNvcnAueWFob28uY29tO0pVNWpzRGRhN3VhSS4yQVRqRi4wWE5jTWl0RHVVYzQyX3luYWd1TjIxaGx6U0lhTXN3LS07NjY2MzM1OzIzNDY3NTsxMjA5MDE2OTE5OzZCM1RBMVNudHdLbl9VdFFKMFEydWctLQ==</Token>
- </Response>
- <?xml version="1.0" encoding="utf-8"?>
- <yahoo:error xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xml:lang="en-US">
- <yahoo:description>description</yahoo:description>
- <yahoo:detail>
- <ErrorCode>errorCode</ErrorCode>
- </yahoo:detail>
- </yahoo:error>
- @XmlRootElement("Response")
- class Response {
- public int responseCode;
- public String responseMessage;
- public String token; // or perhaps byte[] works for automated base64?
- }
Add Comment
Please, Sign In to add comment