小编San*_*kar的帖子

如何将本地xml文件转换为org.ksoap2.serialization.SoapObject?

我正在开发需要连接web服务以响应的android web应用程序.

我正在使用kSOAP进行Web服务调用过程.[kSOAP是用于约束Java环境(如Applet或J2ME应用程序)的SOAP Web服务客户端库.

如果我将响应的xml保存到本地目录中,例如./mnt/sdcard/appData/config.xml然后当我询问Web服务请求时,首先它将检查本地文件是否存在然后将该文件视为响应文件,否则连接到服务器.

此过程缩短了响应时间并提高了应用效率.

是否可以将它('config.xml')转换为SOAP对象?如何?

考虑我的xml本地文件如下:

config.xml中

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Response xmlns="http://testuser.com/webservices/response">
<Result>
<SName>Test User</SName>
<UnitDesc>SAMPLE Test </UnitDesc> <RefreshRate>60</RefreshRate>
<Out>
<Definition>
<Code>ABC</Code>
<Description>(Specific)</Description>
<Action>true</Action>
<Despatch>false</Despatch>
</Definition>
<Definition>
<Code>CDE</Code><Description>(Specific)</Description>
<ActionDate>true</ActionDate>
</Definition>
</Out>
<SampleText>
<string>Test XML Parsing</string>
<string>Check how to convert it to SOAP response</string>
<string>Try if you know</string>
</SampleText>
<GeneralData>
<Pair>
<Name>AllowRefresh</Name>
<Value>Y</Value>
</Pair>
<Pair>
<Name>ListOrder</Name>
<Value>ACCENDING</Value>
</Pair>
</GeneralData>
</Result>
</Response>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)

当前代码如下所示:

final String CONFIGURATION_FILE="config.xml";
File demoDataFile = …
Run Code Online (Sandbox Code Playgroud)

java xml android xml-serialization xml-parsing

12
推荐指数
1
解决办法
2446
查看次数

如何在KSOAP2中将transport.dump大小从256字节增加到512或更多字节?

我有来自KSOAP2库的HttpTransportSE对象.我想转储响应文件,其中可能包含mote然后简单的9697字符.目前我正在做运输.

transport.debug = true;
System.out.println("Response ----------"+transport.responseDump);
Run Code Online (Sandbox Code Playgroud)

但它给了我一半的反应......最后.

在其内部编码结构中,我发现它使用256个字节来创建和销毁它的responseDump,如下所示:

package org.ksoap2.transport;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.util.List;
import org.ksoap2.HeaderProperty;
import org.ksoap2.SoapEnvelope;
import org.xmlpull.v1.XmlPullParserException;

public class HttpTransportSE extends Transport
{
  private ServiceConnection connection;

  public HttpTransportSE(String url)
  {
    super(null, url);
  }

  public HttpTransportSE(Proxy proxy, String url)
  {
    super(proxy, url);
  }

  public HttpTransportSE(String url, int timeout)
  {
    super(url, timeout);
  }

  public HttpTransportSE(Proxy proxy, String url, int …
Run Code Online (Sandbox Code Playgroud)

xml android xmlhttprequest xml-parsing android-ksoap2

10
推荐指数
1
解决办法
833
查看次数

为什么Lucene.NET在索引大文件时会导致OutOfMemoryException?

我已经添加了上面提到的代码IndexWriter.

我已经设定

writer.SetRAMBufferSizeMB(32);
writer.MergeFactor = 1000;
writer.SetMaxFieldLength(Int32.MaxValue);
writer.UseCompoundFile = false;
Run Code Online (Sandbox Code Playgroud)

所有财产都要避免OutOfMemoryException(OOMException).

这里的代码在线writer.AddDocument(document);显示OOM异常.

你能指导我为什么我这个错误吗?
任何人都可以帮我解决这个问题吗?

我的机器配置:
系统类型:64位操作系统.
RAM:4 GB(3.86 GB可用)
处理器:Intel i5 - 3230M CPU @ 2.60GHz

using System;
using System.Data.SqlClient;
using Lucene.Net.Documents;
using System.Data;
using Lucene.Net.Analysis.Standard;
using Lucene.Net.Search;
using Lucene.Net.Store;
using Lucene.Net.QueryParsers;

namespace ConsoleApplication1
{
    class Program
    {
        static String searchTerm = "";
        static void Main(string[] args) {
            /**
             * This will create dataset according to
             * connectingString and query
             **/
            Console.WriteLine("Connecting to Sql …
Run Code Online (Sandbox Code Playgroud)

lucene lucene.net

8
推荐指数
1
解决办法
850
查看次数

如何使用单个solr实例或Solr Template字段无法正常工作来索引和搜索位于同一数据源中的两个不同表

我想索引并搜索两个不同的实体.

文件名:db-data-config.xml

<dataConfig>
    <dataSource name="myindex" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://test-pc:1433;DatabaseName=SampleDB" user="username" password="password" />
    <document>


     <entity name="Employees" query="select * from employee" transformer="TemplateTransformer" dataSource="myindex">
            <field column="id" name="singlekey" />
            <field column="eId" name="eid" />
            <field column="eName" name="ename" />
            <field column="entity" template="Employee" name="entity" />
    </entity>

    <entity name="Products" query="select * from products" transformer="TemplateTransformer" dataSource="myindex">
            <field column="id" name="singlekey" />
            <field column="pId" name="pid" />
            <field column="pName" name="pname" />
            <field column="entity" template="Product" name="entity" />
    </entity>

</document>
Run Code Online (Sandbox Code Playgroud)

文件名:schema.xml

<?xml version="1.0" encoding="UTF-8" ?>
<schema name="db" version="1.1">
  <types>
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/> …
Run Code Online (Sandbox Code Playgroud)

xml indexing solr data-import dataimporthandler

8
推荐指数
1
解决办法
1442
查看次数

如何在 SOLR DIH HTTP API 中强制中止数据导入

请按照以下步骤生成错误:

1. Configure the large amount of data (around 4 GB or more than 50 millions of records)
2. Give proper data-config.xml file for indexing the data from remote database server.
3. During indexing the data into solr from SQL SERVER 2010, at the half way unplug the     
   network cable and see the status in solr. e.g.
   localhost:8083/solr/core1/dataimport?command=status
   or
   localhost:8083/solr/core1/dataimport
4. Pass few seconds then again plug back the cable.
5. You can clearly see that there is just only …
Run Code Online (Sandbox Code Playgroud)

indexing solr solrnet solrj

5
推荐指数
1
解决办法
5293
查看次数

如何在三元运算符中编写多个语句?

我发布这个问题是因为我没有发现关于此类帖子的任何类似内容。 我正在学习三元运算符。 我想执行如下所示的操作:

  bool Divisible = false;
  foreach (var Number in NumberList))
  {
    var  Number = 242;
    if ((Number %= 2) | (Number %= 6))
    {
       Divisible = true;
    }
    else
    {
       Divisible = false;
    }
  }
Run Code Online (Sandbox Code Playgroud)

我们可以使用三元运算符这样写:

var Divisible = (Number %= 2 | Number %= 6) ? false : true ;
Run Code Online (Sandbox Code Playgroud)

但是如果在 else 块中有多个语句,那么该怎么办?

  bool Divisible = false;
  foreach (var Number in NumberList))
  {
    var  Number = 242;
    if ((Number %= 2) | (Number %= 6))
    { …
Run Code Online (Sandbox Code Playgroud)

c# operators ternary-operator c#-4.0

5
推荐指数
1
解决办法
2520
查看次数