我们如何在android中的soap请求后传递值?

时间:2013-11-05 09:58:31

标签: android web-services soap

下面的soap请求如何传递Destinationurl,Fields,FieldInformation值,如type,Internalname

<soap:Body>
<CopyIntoItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  <SourceUrl>string</SourceUrl>
  <DestinationUrls>
    <string>string</string>
    <string>string</string>
  </DestinationUrls>
  <Fields>
    <FieldInformation Type="Invalid or Integer or Text or Note or DateTime or Counter       or Choice or Lookup or Boolean or Number or Currency or URL or Computed or Threading or Guid or MultiChoice or GridChoice or Calculated or File or Attachments or User or Recurrence or CrossProjectLink or ModStat or AllDayEvent or Error" DisplayName="string" InternalName="string" Id="guid" Value="string" />
    <FieldInformation Type="Invalid or Integer or Text or Note or DateTime or Counter or Choice or Lookup or Boolean or Number or Currency or URL or Computed or Threading or Guid or MultiChoice or GridChoice or Calculated or File or Attachments or User or Recurrence or CrossProjectLink or ModStat or AllDayEvent or Error" DisplayName="string" InternalName="string" Id="guid" Value="string" />
  </Fields>
  <Stream>base64Binary</Stream>
</CopyIntoItems>
</soap:Body>

1 个答案:

答案 0 :(得分:0)

试试这个。

       URL url = new URL(Url);
       URLConnection connection = url.openConnection();
       HttpURLConnection httpConn = (HttpURLConnection) connection;
       String SOAPAction = "";

将您的soap请求转换为字符串。

       byte[] b =s_body.getBytes();//make your soap request string as array byte.

       // Set the appropriate HTTP parameters.
       httpConn.setRequestProperty( "Content-Length", String.valueOf( b.length ) );
       httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8");
       httpConn.setRequestProperty("SOAPAction",SOAPAction);
       httpConn.setRequestMethod("POST");

       httpConn.setDoOutput(true);
       httpConn.setDoInput(true);


       // Everything's set up; send the XML that was read in to b.
      OutputStream o = httpConn.getOutputStream();
       o.write(b);
       o.close();