SharePoint - SOAP Request To Web Services Returns List Of Operations - sharepoint

I have a VB script that is supposed to grab a specific list item from SharePoint 2013 via web services.
Relevant code:
Dim response, request, colItem, objItem
Dim fileSystem: Set fileSystem = CreateObject("Scripting.FileSystemObject")
request = "<?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>" & _
" <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" & _
" <listName>{FC3E18D6-33E5-4032-BE4B-F0F92F6F18BA}</listName>" + _
" <viewName>{2861DF9F-11F8-4E4B-A318-D4D37C1C5169}</viewName>" + _
" <query></query>" & _
" </GetListItems>" & _
" </soap:Body>" & _
"</soap:Envelope>"
http.open "POST", "http://<redacted>/_vti_bin/Lists.asmx", False
http.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
http.setRequestHeader "Content-Length", Len(request)
http.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems"
http.send request
However, it is just returning the same page that I see if I navigate directly to .../_vti_bin/Lists.asmx, which is the list of supported operations. If I click on "GetListItems", the example XML it provides looks like what I have in the VB script, except for a few parameters which I believe are optional:
POST /_vti_bin/Lists.asmx HTTP/1.1
Host: <redacted>
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetListItems"
<?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>
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>string</listName>
<viewName>string</viewName>
<query>string</query>
<viewFields>string</viewFields>
<rowLimit>string</rowLimit>
<queryOptions>string</queryOptions>
<webID>string</webID>
</GetListItems>
</soap:Body>
</soap:Envelope>
I have Googled around and been unable to find what I am doing wrong.
Thanks

Instead of GUID try using the regular names of the list and views for the listName and viewName XML elements.
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>My List</listName>
<viewName>All Items</viewName>
</GetListItems>
Here's a sample code I used on my SP 2013 site with jQuery.
$.ajax({
type: "POST",
contentType: "text/xml; charset=utf-8",
url: "https://site/_vti_bin/Lists.asmx",
data: '<?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> <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>My Test Cases</listName> </GetListItems> </soap:Body> </soap:Envelope>',
dataType: "xml",
success: function (msg) {
console.log(msg);
},
error: function (data, status, error) {
console.log('error');
}
});

Related

My SOAP post response is not returning 200 in Python, but it works in Postman

So I ran my post method for SOAP in Postman and received 200, the response headers had text/xml; charset=utf-8 for Content type. My Headers in Postman excluding the default values are
ClientID 700,
SOAPAction urn,
Content-Type text/xml
url = www.xyz.com.svc
The SOAP raw XML used to run in Postman.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.xsd" xmlns:wsu="http://docs.oa.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1234">
<wsse:Username>E</wsse:Username>
<wsse:Password Type="http://docs.o-username-token-profile-1.0#PasswordText">abcd</wsse:Password>
<wsse:Nonce EncodingType="http://docs.o.security-1.0#Base64Binary">happy</wsse:Nonce>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ConfirmAppointment xmlns="urn:CompanyNameServices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--string occurs:0,1-->
<PatID xsi:nil="false">A1</PatID>
<!--string occurs:0,1-->
<PIDType xsi:nil="false">B</PIDType>
<!--string occurs:0,1-->
<MyCID xsi:nil="false">1</MyCID>
<!--string occurs:0,1-->
<MIDType xsi:nil="false">External</MyIDType>
<!--string occurs:0,1-->
<AppCID xsi:nil="false">1</AppCID>
</ConfirmAppointment>
</soapenv:Body>
</soapenv:Envelope>
I am trying to run this using Python requests.post, here is my code.
soap_body = '''
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.xsd" xmlns:wsu="http://docs.oa.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1234">
<wsse:Username>E</wsse:Username>
<wsse:Password Type="http://docs.o-username-token-profile-1.0#PasswordText">abcd</wsse:Password>
<wsse:Nonce EncodingType="http://docs.o.security-1.0#Base64Binary">happy</wsse:Nonce>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ConfirmAppointment xmlns="urn:CompanyNameServices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--string occurs:0,1-->
<PatID xsi:nil="false">A1</PatID>
<!--string occurs:0,1-->
<PIDType xsi:nil="false">B</PIDType>
<!--string occurs:0,1-->
<MyCID xsi:nil="false">1</MyCID>
<!--string occurs:0,1-->
<MIDType xsi:nil="false">External</MyIDType>
<!--string occurs:0,1-->
<AppCID xsi:nil="false">1</AppCID>
</ConfirmAppointment>
</soapenv:Body>
</soapenv:Envelope>'''
headers = {
'ClientID': '700',
'SOAPAction': 'urn',
'Content-Type': 'text/xml'
}
response = requests.post(url=url, data=soap_body, headers=headers)
print(response)
My output:
<Response [500]>
If I add <?xml version="1.0" encoding="UTF-8"?> to the beginning of my body, my output:
<Response [400]>
What am I doing wrong here?
Here are 2 sample SOAP requests. See if they work for you.
import requests
url = "https://httpbin.org/post"
headers = {"content-type" : "application/soap+xml"}
body = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="https://httpbin.org/post">
<soapenv:Header/>
<soapenv:Body/>
</soapenv:Envelope>
""".strip()
response = requests.post(url, data = body, headers = headers)
print(response.content.decode("utf-8") +'\n')
###########################################
url = "https://www.dataaccess.com/webservicesserver/NumberConversion.wso"
headers = {"content-type" : "application/soap+xml"}
body = """
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">
<ubiNum>500</ubiNum>
</NumberToWords>
</soap:Body>
</soap:Envelope>
""".strip()
response = requests.post(url, data = body, headers = headers)
print(response.content.decode("utf-8") +'\n')

DocuSign NO_DOCUMENT_RECEIVED

I am following the Docusign guide to upload PDF for signing. I get the error message NO_DOCUMENT_RECEIVED. Can you guide me on what could be causing this ? I am using JDK 8/Win 7/64bit and IDE is Netbeans 7.0.0.1
TIA !
Ruben.
Here is a trace log:
Info: ***** IN SIGN DOCUMENT *****
Info: ***** IN DOCUSIGN AUTHENTICATION *****
Info: STEP 1: Sending Login request...
Info: ***** BASEURL:https://demo.docusign.net/restapi/v2/accounts/1323921 *****
Info: ***** accountID:1323921 *****
Info: ***** IN CREATE ENVELOPE *****
Info: -- Login response --
<?xml version="1.0" encoding="UTF-8"?><loginInformation xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<loginAccounts>
<loginAccount>
<accountId>1323921</accountId>
<baseUrl>https://demo.docusign.net/restapi/v2/accounts/1323921</baseUrl>
<email>MYEMAIL#ABC.COM</email>
<isDefault>true</isDefault>
<name>COMPANY</name>
<siteDescription/>
<userId>23fffd08-d461-4a12-b3e4-8a6528dd2a69</userId>
<userName>Ruben</userName>
</loginAccount>
</loginAccounts>
</loginInformation>
Info: ***** IN SEND CONTRACT *****
Info: SIZE IN BYTES : 513625
Info: ***** request body start *****
Info:
--BOUNDARY
Content-Type: application/xml
Content-Disposition: form-data
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
<emailSubject>API Call for adding signature request to document and sending</emailSubject>
<status>sent</status>
<documents>
<document>
<documentBase64></documentBase64> //inserting length of packet (513625) throws invaild size message here
<documentId>1</documentId>
<name>ERS.pdf</name>
</document>
</documents>
<recipients>
<signers>
<signer>
<recipientId>1</recipientId>
<name>Ruben</name>
<email>MYEMAIL#ABC.COM</email>
<tabs>
<signHereTabs>
<signHere>
<xPosition>175</xPosition>
<yPosition>122</yPosition>
<documentId>1</documentId>
<pageNumber>12</pageNumber>
</signHere>
</signHereTabs>
</tabs>
</signer>
</signers>
</recipients>
</envelopeDefinition>
--BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="ERS.pdf"; documentid="1"
Info: [B#50ce7292
Info:
--BOUNDARY--
Info: ***** request body end *****
Info: API call failed, status returned was: 400
Info: Error description:
<?xml version="1.0" encoding="UTF-8"?><errorDetails xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<errorCode>NO_DOCUMENT_RECEIVED</errorCode>
<message>The document element did not contain the encoded document, or there is a problem with the encoding. Bytes for document corresponding to documentId 1 not found in request. 'documentId=<x>' possibly missing from Content-Disposition header.</message>
</errorDetails>
Rewrite the default initializeRequest for handling mutipart uploads so just before upload change the multipart value to true in all other cases such as login set it to false.
private static HttpURLConnection initializeRequest(String url, String method,
String body, String httpAuthHeader, Boolean multipart) {
HttpURLConnection conn = null;
try {
conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod(method);
conn.setRequestProperty("X-DocuSign-Authentication", httpAuthHeader);
conn.setRequestProperty("Accept", "application/xml");
conn.setDoOutput(true);
if (multipart) {
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=BOUNDARY");
} else {
conn.setRequestProperty("Content-Type", "application/xml");
if (method.equalsIgnoreCase("POST") || method.equalsIgnoreCase("PUT") || method.equalsIgnoreCase("DELETE")) {
conn.setRequestProperty("Content-Length", Integer.toString(body.length()));
DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
dos.writeBytes(body);
dos.flush();
dos.close();
}
}
return conn;
} catch (Exception e) {
throw new RuntimeException(e);
}
}

Boundary not found in request

I am getting the error:
An error was found while parsing the multipart request. Boundary terminator '--BOUNDARY--' was not found in the request.
I have tried debugging with Firefox and chrome with same results.
Any help would be greatly appreciated.
Here is the code I am using:
Public Sub configureMultiPartFormDataRequest(ByVal request As HttpWebRequest, _
ByVal xmlBody As String, _
ByVal docName As String)
'Overwrite the default content-type header and set a boundary marker
request.ContentType = "multipart/form-data; boundary=BOUNDARY"
'Start building the multipart request body
Dim requestBodyStart As String = "\r\n\r\n--BOUNDARY\r\n" + _
"Content-Type: application/xml\r\n" + _
"Content-Disposition: form-data\r\n" + _
"\r\n" + _
xmlBody + "\r\n\r\n--BOUNDARY\r\n" + _
"Content-Type: application/pdf\r\n" + _
"Content-Disposition: file; filename=\" + docName + " \ documentId=1\r\n" + _
"\r\n"
Dim requestBodyEnd As String = "\r\n--BOUNDARY--\r\n\r\n"
'Read the contents of provided document into the request stream
Dim fileStream As FileStream = File.OpenRead(docName)
'Write the body of the request
Dim bodyStart() As Byte = System.Text.Encoding.UTF8.GetBytes(requestBodyStart.ToString())
Dim bodyEnd() As Byte = System.Text.Encoding.UTF8.GetBytes(requestBodyEnd.ToString())
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(bodyStart, 0, requestBodyStart.ToString().Length)
'Read the file contents and write them to the request stream. (4096 Byte Blocks)
Dim buf(4096) As Byte
'Dim len As Integer
'While ((len = fileStream.Read(buf, 0, 4096)) > 0)
' dataStream.Write(buf, 0, len)
'End While
Dim bytesRead As Integer
Do
bytesRead = fileStream.Read(buf, 0, buf.Length)
If bytesRead > 0 Then
dataStream.Write(buf, 0, bytesRead)
End If
Loop While bytesRead > 0
dataStream.Write(bodyEnd, 0, requestBodyEnd.ToString().Length)
dataStream.Close()
End Sub
Added 05/09/2014
Here is the actual request text from Fiddler2. It appears that the bodyEnd is being set to "PDF-1.7". I have searched the code for this string without success. Thanks for your help: \r\n\r\n--BOUNDARY\r\nContent-Type: application/xml\r\nContent-Disposition: form-data\r\n\r\nsentDocuSign API - Embedded Signing example1\10.1.11.100\SecureDocs\EnrollmentForms\CrystalReport1.pdf1hmitchell#ata.eduA Adams10010011\r\n\r\n--BOUNDARY\r\nContent-Type: application/pdf\r\nContent-Disposition: file; filename=\XXX\; documentId=1\r\n\r\n%PDF-1.7
David
Thanks for your fix for the BOUNDARY error. I implemented your xml example and now get an error: "The document element did not contain the encoded document, or there is a problem with the encoding."
Here is the request:
--BOUNDARY
Content-Type: application/xml
Content-Disposition: form-data
sentDocuSign API - Embedded Signing example1C:\Hold\myXML.xml1hmitchell#ata.eduA Adams10010011
--BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename=\C:\Hold\myXML.xml \ documentId=1
<nameValue>
<name>canManageAccount</name>
<value>false</value>
</nameValue>
--BOUNDARY--
Thanks for your help!!!
Your code snippet above is missing the calling method so I made my own as shown below to demonstrate how to leverage WebHookapp endpoint to capture what is being sent. So I think you will see that the body is not formatted correctly due to the fact you tried to "escape" the line breaks and carriage return values vs using the chr with the correct value.
Code I added to call you above method
Imports System.IO
Imports System.Net
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim myHTTPRequest As System.Net.HttpWebRequest = WebRequest.Create("http://webhookapp.com/1037371688646089664")
Dim myXML As String = "{SomeXMLorJason: sampleNotFormatedcorrectly}"
Dim myDocName As String = "c:\myXML.xml"
myHTTPRequest.Method = "POST"
configureMultiPartFormDataRequest(myHTTPRequest, myXML, myDocName)
myHTTPRequest.GetResponse()
End Sub
'Your Code goes here ---> from above:
End Class
What is in the file c:\myXML.xml
<nameValue>
<name>canManageAccount</name>
<value>false</value>
</nameValue>
What was sent:
POST /1037371688646089664
content-type multipart/form-data; boundary=BOUNDARY
host webhookapp.com
content-length 439
expect 100-continue
connection Keep-Alive
\r\n\r\n--BOUNDARY\r\nContent-Type: application/xml\r\nContent-Disposition: form-data\r\n\r\n{SomeXMLorJason: sampleNotFormatedcorrectly}\r\n\r\n--BOUNDARY\r\nContent-Type: application/pdf\r\nContent-Disposition: file; filename=\c:\myXML.xml \ documentId=1\r\n\r\n <nameValue>
<name>canManageAccount</name>
<value>false</value>
</nameValue>\r\n--BOUNDARY--\r\n\r\n
What to do to fix your code:
'Start building the multipart request body
' http://www.asciitable.com/
Dim asciLN As String = Chr(10)
Dim asciCR As String = Chr(13)
Dim requestBodyStart As String = asciCR + asciLN + asciCR + asciLN + "--BOUNDARY" + asciCR + asciLN + _
"Content-Type: application/xml" + asciCR + asciLN + _
"Content-Disposition: form-data" + asciCR + asciLN + _
asciCR + asciLN + _
xmlBody + asciCR + asciLN + asciCR + asciLN + "--BOUNDARY" + asciCR + asciLN + _
"Content-Type: application/pdf" + asciCR + asciLN + _
"Content-Disposition: file; filename=\" + docName + " \ documentId=1" + asciCR + asciLN + _
asciCR + asciLN
Dim requestBodyEnd As String = asciCR + asciLN + "--BOUNDARY--" + asciCR + asciLN + asciCR + asciLN
Which will yield:
POST /1037371688646089664
content-type multipart/form-data; boundary=BOUNDARY
host webhookapp.com
content-length 409
expect 100-continue
connection Keep-Alive
--BOUNDARY
Content-Type: application/xml
Content-Disposition: form-data
{SomeXMLorJason: sampleNotFormatedcorrectly}
--BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename=\c:\myXML.xml \ documentId=1
<nameValue>
<name>canManageAccount</name>
<value>false</value>
</nameValue>
--BOUNDARY--
And a general envelope in JSON as Multipart should look like below:
POST http://{server}/restapi/{apiVersion}/accounts/{accountId}/envelopes
X-DocuSign-Authentication: <DocuSignCredentials><Username>{name}</Username><Password>{password}</Password><IntegratorKey>{integrator_key}</IntegratorKey></DocuSignCredentials>
Accept: application/json
Content-Type: multipart/form-data; boundary=AAA
--AAA
Content-Type: application/json
Content-Disposition: form-data
{
"status":"sent",
"emailBlurb":"Test Email Body",
"emailSubject": "Test Email Subject - EnvelopeDefFull",
"documents": [{
"name": "test1.pdf",
"documentId":"1"
"order":"1"
}],
"recipients": {
"signers" : [{
"email": "test#email.com",
"name": "Sally Doe",
"recipientId":"1",
}]
}
}
--AAA
Content-Type: application/pdf
Content-Disposition: file; filename="test1.pdf";documentid=1
<document bytes removed>
--AAA--
Generally speaking your request should look like the following. The only difference is that this example used JSON format instead of XML. Only change you need to make is changing application/json to application/xml for the Content-Type, then change the JSON data to XML format instead.
POST http://{server}/restapi/{apiVersion}/accounts/{accountId}/envelopes
X-DocuSign-Authentication: <DocuSignCredentials><Username>{name}</Username><Password>{password}</Password><IntegratorKey>{integrator_key}</IntegratorKey></DocuSignCredentials>
Accept: application/json
Content-Type: multipart/form-data; boundary=AAA
--AAA
Content-Type: application/json
Content-Disposition: form-data
{
"status":"sent",
"emailBlurb":"Test Email Body",
"emailSubject": "Test Email Subject - EnvelopeDefFull",
"documents": [{
"name": "test1.pdf",
"documentId":"1"
"order":"1"
}],
"recipients": {
"signers" : [{
"email": "test#email.com",
"name": "Sally Doe",
"recipientId":"1",
}]
}
}
--AAA
Content-Type: application/pdf
Content-Disposition: file; filename="test1.pdf";documentid=1
<document bytes removed>
--AAA--
Without seeing the actual request that your code is constructing and sending I can only assume something is wrong with the formatting. Ensure that you have extra newlines (CRLF) where needed and that the document bytes are correctly being written to the request. If you're still stuck you might want to run through a tool such as Fiddler to check the request data...

Sharepoint returns double encoded strings?

I'm using CURL to extract data from a sharepoint list. Now, I'm facing the problem that the data returned from sharepoint is double encoded (e.g. '>' does not become '>' but instead '&gt;'). How can I work around this?
Example call:
POST /sites/00133/_vti_bin/Lists.asmx HTTP/1.1
User-Agent: curl/7.26.0
Host: team.sp.wp.intra.net
Accept: */*
Content-Type: text/xml; charset=utf8
SOAPAction: http://schemas.microsoft.com/sharepoint/soap/GetListItems
<?xml version='1.0' encoding='utf-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:ns4630='http://tempuri.org'>
<SOAP-ENV:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>{D44FAB23-172F-4756-B573-3E903D21F468}</listName>
<viewName>{79D163F7-3750-49DD-9782-AE9F15B35268}</viewName>
<queryOptions><QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions></queryOptions>
<query><Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">0023120112</Value></Eq></Where></Query></query>
</GetListItems>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Example resonse:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
SPRequestGuid: 7ec7d0cc-2be3-4884-a54f-bb6883eb3584
X-SharePointHealthScore: 0
X-AspNet-Version: 2.0.50727
Persistent-Auth: true
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 14.0.0.7102
X-MS-InvokeApp: 1; RequireReadOnly
Date: Thu, 30 Jan 2014 12:22:17 GMT
Content-Length: 1967
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="h
ttp://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetListItemsResult>
<listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2 A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'>
<rs:data ItemCount="1">
<z:row ows_LinkTitle='0023120112' ows_Issue_x0020_Name='Test' ows_Description='VPC --&gt; please consider Attachment
' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='947;#{0FAF4F6D-7952-4771-86C2-81DC3CDB2EAF}' ows_FSObjType='947;#0' ows_Created_x0020_Date='947;#2014-01-07 07:27:04' ows_Modified='2014-01-30 13:10:19' ows_MetaInfo='947;#' ows_ID='947' ows_owshiddenversion='612' ows_Created='2014-01-07 07:27:04' ows_Title='0023120112' ows_FileLeafRef='947;#947_.000' ows_PermMask='0x7fffffffffffffff' ows_FileRef='947;#sites/00133/Lists/Post Go Live Issue Tracking/947_.000' />
</rs:data>
</listitems>
</GetListItemsResult>
</GetListItemsResponse>
</soap:Body>
</soap:Envelope>

Post soap envelope from bash script

How would I post the following soap envelope via a bash script.
In PHP I would post using cURL but don't know how to translate into bash?
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<n:Request xmlns:n="http://www.****.com/iprs/soap" env:role="http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver" env:mustUnderstand="true">UserMod</n:Request>
</env:Header>
<env:Body>
<n:RequestUserMod xmlns:n="http://www.****.com/iprs/soap">
<n:UserID>****</n:UserID>
<n:UserData >
<n:SystemName>****</n:SystemName>
<n:AdminState>enabled</n:AdminState>
<n:CategoryTypeID>****</n:CategoryTypeID>
<n:Permissions>****</n:Permissions>
<n:BillingProgID>****</n:BillingProgID>
<n:DefaultGroupID>****</n:DefaultGroupID>
<n:PrimarySiteID>****</n:PrimarySiteID>
<n:SecondarySiteID>****</n:SecondarySiteID>
<n:ContactInfo></n:ContactInfo>
<n:Password>****</n:Password>
</n:UserData>
</n:RequestUserMod>
</env:Body>
</env:Envelope>
If possible I would also like to detect the response, which should be:
HTTP/1.1 200 OK
Content-Type:application/soap+xml; charset="utf-8"
Content-Length:509
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Header>
<n:Response xmlns:n="http://www.*****.com/iprs/soap" env:role="http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver" env:mustUnderstand="true">UserMod</n:Response>
</env:Header>
<env:Body>
<n:ResponseUserMod xmlns:n="http://www.*****.com/iprs/soap">
<n:StatusReport>
<n:Code>ok</n:Code>
<n:SubCode>0</n:SubCode>
</n:StatusReport>
</n:ResponseUserMod>
</env:Body>
</env:Envelope>
Perhaps like this?
curl --data - --request "POST" "http://www.somesite.com" <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<n:Request xmlns:n="http://www.****.com/iprs/soap" env:role="http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver" env:mustUnderstand="true">UserMod</n:Request>
</env:Header>
<env:Body>
<n:RequestUserMod xmlns:n="http://www.****.com/iprs/soap">
<n:UserID>****</n:UserID>
<n:UserData >
<n:SystemName>****</n:SystemName>
<n:AdminState>enabled</n:AdminState>
<n:CategoryTypeID>****</n:CategoryTypeID>
<n:Permissions>****</n:Permissions>
<n:BillingProgID>****</n:BillingProgID>
<n:DefaultGroupID>****</n:DefaultGroupID>
<n:PrimarySiteID>****</n:PrimarySiteID>
<n:SecondarySiteID>****</n:SecondarySiteID>
<n:ContactInfo></n:ContactInfo>
<n:Password>****</n:Password>
</n:UserData>
</n:RequestUserMod>
</env:Body>
</env:Envelope>
EOF
to post:
cat file | curl ...
but to retrieve the result, and act according to it, embed it all in a expect script.

Resources