如何删除i:type ="d:string"在KSOAP2 Android中从SOAP的PropertyInfo中获取 [英] How to remove i:type="d:string" from PropertyInfo of SOAP in KSOAP2 Android

查看:114
本文介绍了如何删除i:type ="d:string"在KSOAP2 Android中从SOAP的PropertyInfo中获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用kso​​ap2-android-assembly-3.0.0-jar-with-dependencies.jar

I am using ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar

我正在一个需要以下肥皂请求的项目中

I am working on a project where i need the following soap request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mod="http://www.tmforum.org/xml/tip/model" xmlns:cust="http://www.tmforum.org/xml/tip/customer/cust">
   <soapenv:Header/>
   <soapenv:Body>
      <mod:listProblemsRequest>
         <!--Optional:-->
         <mod:customer>

            <cust:iD >1100000677</cust:iD>
         </mod:customer>


      </mod:listProblemsRequest>
   </soapenv:Body>
</soapenv:Envelope>

但是使用KSOAP2,我可以生成以下请求:

but using KSOAP2 I am able to generate the following request:

<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>
      <retrieveCustomerProfileRequest xmlns="http://www.tmforum.org/xml/tip/model">
           <n0:customer xmlns:n0="http://www.tmforum.org/xml/tip/model">
               <n1:iD i:type="d:string" xmlns:n1="http://www.tmforum.org/xml/tip/customer      /cust">1100000990</n1:iD> 
   </n0:customer>
   </retrieveCustomerProfileRequest>
  </v:Body>
</v:Envelope>

如何从SOAP请求中删除i:type="d:string".

How do I remove i:type="d:string" from the SOAP request.

请提出可以在KSOAP2的源代码中完成的解决方案或任何变通办法,以便我能够生成适当的请求.

Please suggest a solution or any Workaround that could be done in Source code of KSOAP2 so that I may be able to generate the appropriate request.

推荐答案

我在ksoap中找到了解决我的问题的方法:

I have found a workaround to my problem in ksoap :

1. Download the source code of Ksoap2.jar.
2.open up Transport .java and edit its :

    protected byte[] createRequestData(SoapEnvelope envelope, String encoding)
                throws IOException  

Method.

3.i edited it as follows:


protected byte[] createRequestData(SoapEnvelope envelope, String encoding)
            throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream(bufferLength);
        byte result[] = null;
        bos.write(xmlVersionTag.getBytes());
        XmlSerializer xw = new KXmlSerializer();
        xw.setOutput(bos, encoding);
        envelope.write(xw);
        xw.flush();
        bos.write('\r');
        bos.write('\n');
        bos.flush();
        result = bos.toByteArray();
        xw = null;
        bos = null;


        String requestObject = new String(result);
        String pattern = "i:type=\"d:string\"";

        String resultString="";

        System.out.println("==earlier String==" + requestObject);
        if (requestObject.contains(pattern)) {

            System.out.println("==is it here ");
            resultString=requestObject.replace(pattern, "");

}

4.compile this class using classpath of ksoap2.jar
5.extract the ksoap2.jar and remove existing transport.class from it.
6.Add newly compiled .class file and make a new jar.
7.import the jar in your project.
Problem solved..

这篇关于如何删除i:type ="d:string"在KSOAP2 Android中从SOAP的PropertyInfo中获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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