<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetPracticeInformation xmlns="http://tempuri.org/">
<sUserName>string</sUserName>
<sUserPassword>string</sUserPassword>
<iPatientId>int</iPatientId>
<bDocument>boolean</bDocument>
<iDocumentId>int</iDocumentId>
<abCypherTextBytes>base64Binary</abCypherTextBytes>
</GetPracticeInformation>
</soap:Body>
</soap:Envelope>
anyOne可以帮助我在soap字符串中传递布尔值,整数值和base64Binary值...
我试过
NSString *uName = @"Name";
NSString *uPassWord = @"PassWord";
BOOL y = TRUE;
BOOL n = FALSE;
int val = 0;
NSMutableData *myData = [[NSMutableData alloc]initWithCapacity:65000];
NSString *soapMessage =[NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n"
"<GetPracticeInformation xmlns=\"http://tempuri.org/\">\n"
"<sUserName>%@</sUserName>\n"
"<sUserPassword>%@</sUserPassword>\n"
"<iPatientId>%d</iPatientId>\n"
"<bDocument>%c</bDocument>\n"
"<iDocumentId>%d</iDocumentId>\n"
"<abCypherTextBytes>%@</abCypherTextBytes>\n"
"</GetPracticeInformation>\n"
"</soap:Body>\n"
"</soap:Envelope>",uName,uPassWord,val,n,val,myData];
但在这种情况下,我得到0字节响应..
2013-10-15 15:19:34.262 SoapXML[1438:11303] DONE. Received Bytes: 0
2013-10-15 15:19:34.263 SoapXML[1438:11303] out put: (null)
2013-10-15 15:19:34.265 SoapXML[1438:11303] Error while parsing the document: Error Domain=SMXMLDocumentErrorDomain Code=1 "Malformed XML document. Error at line 1:1." UserInfo=0x7690650 {LineNumber=1, ColumnNumber=1, NSLocalizedDescription=Malformed XML document. Error at line 1:1., NSUnderlyingError=0x7690540 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 5.)"}
这是传递值的正确方法吗?如何传递布尔值和base64Binary? ..请帮帮我。
答案 0 :(得分:0)
更改此行,因为布尔值需要int值,所以
<bDocument>%c</bDocument>\n to <bDocument>%d</bDocument>\n
答案 1 :(得分:0)
我通过传递结果(mydata的ASCIIEncoding)获得了解决方案
NSMutableData *mydata = [[NSMutableData alloc]initWithCapacity:65000];
NSString *result= [[NSString alloc]initWithData:mydata encoding:NSASCIIStringEncoding];
代替base64Binary,我传递了结果字符串,我正确地得到了响应......