SOAP请求中出现意外的XML输出

时间:2014-02-26 12:50:29

标签: android soap ksoap2 android-ksoap2

我一直在努力争取这一天,我无法正确地格式化我的SOAP请求。这就是我的Soap请求的构建方式:

SoapObject request =  new SoapObject(NAMESPACE,  search);
SoapObject context =  new SoapObject(NAMESPACE, "context");

request.addProperty("pi_csecurity_data", "security token ");

SoapObject mainclass = new SoapObject(NAMESPACE, "mainclass");
mainClass.addAttribute("adm_nr", "621");
mainClass.addAttribute("main_comp_code", "*");

context.addProperty("itmpMcomp", mainClass);
//also tried context.addSoapObject(mainclass); here
request.addSoapObject(context);

这是我的输出:

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header/>
<v:Body>
    <n0:search id="o0" c:root="1" xmlns:n0="namespace">
        <pi_csecurity_data i:type="d:string">security token</pi_csecurity_data>
        <n0:context i:type="n0:context">
            <n0:mainclass i:type="n0:mainclass" adm_nr="621" main_comp_code="*"/>
        </n0:context>
    </n0:search>
</v:Body>

正如你可能看到的那样,我错过了我的结束标签       &LT; n0:mainclass&gt;

任何想法? :)

1 个答案:

答案 0 :(得分:0)

标签并非总是如此:

<tag>...</tag>

如果标签只有像你的情况那样的属性,那么这个语法也是正确的

<tag />