如何在目标c中创建动态肥皂封套 [英] How to create dynamic soap envelop in objective c

查看:19
本文介绍了如何在目标c中创建动态肥皂封套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SOAP 主体

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];

这是一个简单的肥皂消息,你知道.如果我想使用我如何构造它的函数传递 str 的值?

This is a simple soap message you know that.If i want to pass value of str using function that how i construct it?

但是,我想为这个对象传递值,这怎么可能?

But, i want to pass by value for this object how is it possible?

推荐答案

你可以这样做,你必须根据你的要求进行修改:

You can do something like this, you have to do modifications as per your requirement:

//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];

这篇关于如何在目标c中创建动态肥皂封套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆