gpt4 book ai didi

iphone - 如何将 NSDate 发送到 soap web 服务 - .net

转载 作者:行者123 更新时间:2023-11-28 18:42:56 26 4
gpt4 key购买 nike

我有个小问题。我必须将 NSDate 作为参数发送到 soap web 方法。

[WbMethod]
public void Method(DateTime date){...

我从 objective-c 发送这样的数据:

NSDate* date = [NSDate date];

...
NSString *soapMsg =
[NSString stringWithFormat:
@"<?xml...
"<date>%d</date>"
...
"</soap:Body>"
"</soap:Envelope>", date
];

我得到了错误:

...<faultstring>Server was unable to read request. ---&gt; There is an error in XML document (1, 354). ---&gt; The string '93462576' is not a valid AllXsd value.</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>

我也曾尝试将 %d 更改为 %@ 然后错误是:

...faultstring>Server was unable to read request. ---&gt; There is an error in XML document (1, 371). ---&gt; The string '2012-01-26 14:27:45 +0000' is not a valid AllXsd value.</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>

最佳答案

如果应该是你说的格式,那么

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM/dd/yyyy hh,mm,ss"];
NSString *yourDateString = [formatter stringFromDate:[NSDate date]];
[formatter release];

关于iphone - 如何将 NSDate 发送到 soap web 服务 - .net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9019557/

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