如何在目标c中创builddynamicsoap信封
SOAP Body
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" " <Ins_VIP xmlns=\"http://tempuri.org/>\">\n" "<strVIPNo>%@</name>\n" "</name>\n" "</soap:Body>\n" "</soap:Envelope>\n" , str];
这是一个简单的soap消息,你知道这一点。如果我想通过使用函数来传递str的值,我如何构造它?
但是,我想通过这个对象的价值传递怎么可能?
你可以做这样的事情,你必须按照你的要求做修改:
//Add Request key and Values in below arrays NSArray* ReqKeyList; NSArray* ReqValueList; NSString *HeaderPart; NSString *BodyPart = @""; NSString *FooterPart; NSString *soapMessage; HeaderPart = [NSString stringWithFormat:@"<%@ xmlns=\"http://tempuri.org/\">\n",YourFunctionName]; FooterPart = [NSString stringWithFormat:@"</%@>\n", YourFunctionName]; for(int i=0;i<ReqKeyList.count;i++) { if (ReqValueList.count>i){ BodyPart = [BodyPart stringByAppendingString:[NSString stringWithFormat:@"<%@>%@</%@>\n",ReqKeyList[i],ReqValueList[i],ReqKeyList[i]]]; } } 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" "%@" "%@" "%@" "</soap:Body>\n" "</soap:Envelope>\n",HeaderPart,BodyPart,FooterPart];