gpt4 book ai didi

ios - Exchange ActiveSync Objective-C 提供命令错误请求

转载 作者:行者123 更新时间:2023-11-29 13:10:12 25 4
gpt4 key购买 nike

我试错了几天,查看了交易所日志,在网上搜索了很多遍,至今无法解决这个问题。

我正在我的 iOS 应用程序中实现 ActiveSync 功能,到目前为止已经成功地编写了自动发现过程和 HTTP OPTIONS 请求以获取服务器功能。我现在正在尝试运行 Provision 命令,但不断收到 400 Bad Request。

这是我发送给服务器的内容:

URL: https://mobile.[myexchangeserver].com/Microsoft-Server-ActiveSync?Cmd=Provision&User=jack&DeviceID=123412341234&DeviceType=iOS

Authorization = "Basic wekrju283j"; //Base 64 encoded auth, garbage for this posting
"Content-Length" = 104;
"Content-Type" = "application/vnd.ms-sync.wbxml";
"MS-ASProtocolVersion" = "12.1";
"User-Agent" = MyApp;
"X-MS-PolicyKey" = 0;

Body (converted to WBXML before sending):
<?xml version="1.0" encoding="utf-8"?>
<Provision xmlns="Provision:">
<Policies>
<Policy>
<PolicyType>MS-EAS-Provisioning-WBXML</PolicyType>
</Policy>
</Policies>
</Provision>


WBXML: 02 00 25 6A 41 50 72 6F 76 69 73 69 6F 6E 00 50 6F 6C 69 63 69 65 73 00 50 6F 6C 69 63 79 00 50 6F 6C 69 63 79 54 79 70 65 00 2D 2F 2F 41 49 52 53 59 4E 43 2F 2F 44 54 44 20 41 69 72 53 79 6E 63 2F 2F 45 4E 00 44 00 44 0A 44 13 44 1A 03 4D 53 2D 45 41 53 2D 00 83 00 03 69 6E 67 2D 57 42 58 4D 4C 00 01 01 01 01

除了“Bad Request”,我还能找到更多信息吗?或者有人看到我发送的内容有什么问题吗?服务器支持12.1协议(protocol)(来自OPTIONS请求)

我一遍又一遍地阅读了协议(protocol)文档,但仍然找不到我所做的任何错误。我知道我可以对参数进行 base64 编码,但根据可选的协议(protocol)文档。我也知道在 14.1 中我需要在 xml 中发送更多信息,因此我使用 12.1 协议(protocol)。

非常感谢任何帮助。

最佳答案

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URI
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:300.0];
NSString *msgLength = [NSString stringWithFormat:@"%d",[requestBodyData length]];
NSLog(@"Request Body Data Length: %@",msgLength);

[request setHTTPMethod:@"POST"];
[request setValue:mAuthStringFinal forHTTPHeaderField:@"Authorization"];
[request setValue:@"iPhone" forHTTPHeaderField:@"DeviceType"];
[request setValue:@"application/vnd.ms-sync.wbxml" forHTTPHeaderField:@"Content-Type"];
[request setValue:msgLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"12.1" forHTTPHeaderField:@"MS-ASProtocolVersion"];
[request setValue:@"*/*" forHTTPHeaderField:@"Accept"];
[request setValue:@"en-us" forHTTPHeaderField:@"Accept-Language"];
[request setValue:nil forHTTPHeaderField:@"X-MS-PolicyKey"];
[request setHTTPBody:requestBodyData];

NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:request delegate:self];

/* ensure the connection was created */
if (connection)
{
/* initialize the buffer */
buffer = [NSMutableData data];

/* start the request */
[connection start];
}
else
{
NSLog(@"Connection Failed");
}

我在 POST 请求中添加了更多 header ,我收到了 200 状态代码。尝试这个!但是我无法将请求内容作为 wbxml 发送,而 wbxml 又提供了一些无意义的字符作为响应。

关于ios - Exchange ActiveSync Objective-C 提供命令错误请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17581327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com