[請問] 有人有寫過在iphone上用soap呼叫web se …
※ [本文轉錄自 ask 看板 #1CkQcP8C ]
作者: antirazin (~ SNSD & KARA ~ ) 看板: ask
標題: [請問] 有人有寫過在iphone上用soap呼叫web service的經驗嗎?
時間: Sat Oct 16 21:33:09 2010
我想要傳一個wav檔,
但卻不知道該怎麼轉成base64binary,
有人知道怎麼轉嗎?
歡迎丟水球或是回信~感謝
--
推
10/11 21:45,
10/11 21:45
→
10/11 21:46,
10/11 21:46
→
10/11 21:46,
10/11 21:46
→
,
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.206.133
→
10/16 22:06, , 1F
10/16 22:06, 1F
抱歉我打詳細一點好了@@...
NSData *WAVDATA = [NSData dataWithContentsOfFile:thePath];
//上面動作是將指定path的文件用NSData存起來,這邊的文件是一個wav檔
在soapMesssage裡面 <fs>(要傳入參數的位置,型態是base64binary)</fs>
我做了幾種嘗試:
1. 將WAVDATA轉成base64
用網路上找到的NSData+Base64.m
char *EncodedDATA
= NewBase64Encode(WAVDATA, [WAVDATA length], FALSE, &NewLength);
然後傳EncodedDATA
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
//.......中間省略
"<fs>%@</fs>\n"
//.......
"</soap:Body>\n"
"</soap:Envelope>\n",EncodedData
];
結果執行時出現 Program received signal: “EXC_BAD_ACCESS”.
2. 直接傳[WAVDATA bytes]不過也得到同樣情形
3. 直接傳WAVDATA,結果NSLog(soapMessage)秀出:
....
b5bcb8 a0bc28c2 bec5fccb 22cf78d5 b0d8badc 70e188e3 36e5cae9 68eab4e9 a4ecbaeb 3aeb36ea cce95ae8 fae7b8e4 d6e44ce4 10e20ae2 b6e1cce1 58e2c6e2 0ce4b4e6 3ce7f2ea 20ee38f1 18f522f9 3efdfe01 7c05da08 a40e6c11 04157a18 5e1b161d c21fb421 0624ba24 aa256228 a829702a e42bde2c 122f6c2f 38304231 b434b834 a436b038 163a5c3c f63c6e3e b8408642 2c42d044 50456242 4041ae40 f43c6838 c232882c 0229fa1d 9a180011 4a05f4ff bef60ced bae46edd b4d578cd 16c9a8c1 38bc88ba 96b526b4 36b492b1 0eb4dcb4 5ab60cba 98bca6c0 9ac406c9
4ace78d1 b6d654da dadee8e1 e4e334e8 36ea70ea aaebe4ec bcebceeb
....
然後server似乎沒有收到...
16 22:48:07.008 Hello_SOAP[5410:20b] connection: didReceiveResponse:1
2010-10-16 22:48:07.008 Hello_SOAP[5410:20b] DONE. Received Bytes: 0
4. 隨便寫死一個base64binary
<fs>a455d22</fs>
server端終於有動靜了!但是...
2010-10-16 22:59:52.730 Hello_SOAP[5515:20b] connection: didReceiveResponse:1
2010-10-16 22:59:52.731 Hello_SOAP[5515:20b] connection: didReceiveData:2
2010-10-16 22:59:52.732 Hello_SOAP[5515:20b] DONE. Received Bytes: 401
2010-10-16 22:59:52.733 Hello_SOAP[5515:20b]
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="" rel="nofollow">http://www.w3.org/2001/XMLSchema">
<soap:Body>
<UploadWavAndVCResponse
xmlns="" rel="nofollow">http://tempuri.org/"><UploadWavAndVCResult> 索引在陣列的界限之外。</UploadWavAndVCResult>
</UploadWavAndVCResponse></soap:Body></soap:Envelope>
2010-10-16 22:59:52.735 Hello_SOAP[5515:20b] 4 parser didStarElemen: namespaceURI: attributes:
2010-10-16 22:59:52.737 Hello_SOAP[5515:20b] 4 parser didStarElemen: namespaceURI: attributes:
2010-10-16 22:59:52.737 Hello_SOAP[5515:20b] 4 parser didStarElemen: namespaceURI: attributes:
2010-10-16 22:59:52.738 Hello_SOAP[5515:20b] 4 parser didStarElemen: namespaceURI: attributes:
2010-10-16 22:59:52.739 Hello_SOAP[5515:20b] 5 parser: foundCharacters:
2010-10-16 22:59:52.739 Hello_SOAP[5515:20b] 6 parser: didEndElement:
2010-10-16 22:59:52.740 Hello_SOAP[5515:20b] 6 parser: didEndElement:
2010-10-16 22:59:52.740 Hello_SOAP[5515:20b] 6 parser: didEndElement:
2010-10-16 22:59:52.741 Hello_SOAP[5515:20b] 6 parser: didEndElement:
不知道為什麼會這樣@@
希望大家看得懂我的問題
本身算程式新手觀念有錯誤地方請多指正~
※ 編輯: antirazin 來自: 140.114.206.133 (10/16 23:00)
※ 編輯: antirazin 來自: 140.114.206.133 (10/16 23:01)
※ 編輯: antirazin 來自: 140.114.206.133 (10/16 23:01)
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章