我正在使用 Oauth Webservice 开发一个黑莓应用程序。当我发送 GET 请求时,虽然我正确发送了授权标头,但我首先获得了 HTTP 401 状态代码。当我再次调用相同的 Web 服务时,它给出了 HTTP 500 错误。我很困惑,要跟踪错误,无论是来自客户端还是服务器错误。我也在运行 MDS 模拟器。请帮助我解决这个问题。
这是我的代码片段:
private HttpConnection HttpRequestCreate(boolean post) throws IOException,MalformedURIException,PINException, net.rim.device.api.crypto.InvalidKeyException,UnsupportedEncodingException,net.rim.device.api.crypto.NoSuchAlgorithmException ,IllegalStateException,NullPointerException,IllegalArgumentException, CryptoTokenException, CryptoUnsupportedOperationException
{
String Authhdr=null;
uthScheme authScheme = new AuthScheme.Builder(HTTPVerb,URI,Date,Keys)
.setContentMD5(ContentMD5)
.setContentType(ContentType)
.build();
Authhdr = authScheme.getAuthorizedHeader();
if(Authhdr ==null)
throw new NullPointerException("Authorization header cannot be null.Please check whether authorization header is properly generated or not.");
HttpConnection ConnectionHandle = null;
ConnectionHandle=(javax.microedition.io.HttpConnection)
Connector.open(URI, Connector.READ_WRITE, true);
ConnectionHandle.setRequestMethod(HTTPVerb);
ConnectionHandle.setRequestProperty("Date",Date);
ConnectionHandle.setRequestProperty("Host",Host);
ConnectionHandle.setRequestProperty("Authorization", Authhdr);
if(ContentLength!=null)
ConnectionHandle.setRequestProperty("Content-Length",ContentLength);
if(ContentMD5!=null)
ConnectionHandle.setRequestProperty("Content-MD5",ContentMD5);
if(ContentType!=null)
ConnectionHandle.setRequestProperty("Content-Type",ContentType);
return ConnectionHandle;
}
谢谢...