如何在SOAP Web服务中发布数据

时间:2012-04-13 06:56:32

标签: android web-services ksoap2

我有以下XML,我想在 ProductNumber 数量价格中发布记录。

    <?xml version="1.0" encoding="utf-8"?>
<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/">
  <soap:Body>
    <QueryPrices xmlns="xyz">
      <strSessionKey>string</strSessionKey>
      <nDiscountID>int</nDiscountID>
      <objOrderItems>
        <OrderItem>
          <ProductNumber>int</ProductNumber>
          <Quantity>int</Quantity>
          <Price>float</Price>
        </OrderItem>
        <OrderItem>
          <ProductNumber>int</ProductNumber>
          <Quantity>int</Quantity>
          <Price>float</Price>
        </OrderItem>
      </objOrderItems>
    </QueryPrices>
  </soap:Body>
</soap:Envelope>

1 个答案:

答案 0 :(得分:1)

创建Soap对象,只需使用addProperty()传递参数。

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request .addProperty("key", value);

处理SOAP

在你的情况下:

request.addProperty( "ProductNumber","something");
request.addProperty( "Quantity","something");
request.addProperty( "Price","something");