SOAP MTOM attachments with Linux CURL - linux

So far I've been sending attachments with SOAP using simple base64 encoding and placing them inline - all done by CURL. Now I have a new request, where attachments need to be sent as MTOM attachments, the question is: is it possible with linux curl? Probably I would need a content-type of multipart/related or similar.
I can see that it is possible using JAX-WS, but in order to do this we would have to develop a new client which isn't actually the best option for us.
Please, tell me if it is possible, and if yes, give me any hints how to do it.

You can include the file content in base64 encoding and using curl post.
Here is one example:
Have mtom sample from axis2 installed and working for you
Construct the following sample req.xml
$ cat req.xml
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:mtom="http://ws.apache.org/axis2/mtomsample/" xmlns:xm="http://www.w3.org/2005/05/xmlmime">
<soap:Header/>
<soap:Body>
<mtom:AttachmentRequest>
<mtom:fileName>one.txt</mtom:fileName>
<mtom:binaryData xm:contentType="application/txt">SSBhbSB0aGUgZ3JlYXRlc3Qu</mtom:binaryData>
</mtom:AttachmentRequest>
</soap:Body>
</soap:Envelope>
post the request using curl
$ cat req.xml | curl -X POST -H 'Content-type: application/soap+xml' -d #-
http://yourmachine.com:8080/axis2/services/MTOMSample.MTOMSampleSOAP12port_http/
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns2:AttachmentResponse xmlns:ns2="http://ws.apache.org/axis2/mtomsample/">
File saved succesfully.
</ns2:AttachmentResponse>
</soapenv:Body>
</soapenv:Envelope>
Does this work for you?

Related

Node + Soap call works within app, but fails when request is run from Postman

I'm using node and the soap package. The code works and fetches the account info I need. This is legacy code which I'm trying to reverse engineer. When I call the soap packages' client.lastRequest, console.log('last request: ', client.lastRequest) I see the SOAP call that was made:
<?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:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:tns="https://bingads.microsoft.com/Customer/v13"
xmlns:q1="https://adapi.microsoft.com"
xmlns:q2="https://adapi.microsoft.com"
xmlns:q3="https://adapi.microsoft.com"
xmlns:q4="https://adapi.microsoft.com"
xmlns:q5="https://adapi.microsoft.com"
xmlns:q6="https://adapi.microsoft.com"
xmlns:q7="https://adapi.microsoft.com"
xmlns:q8="https://adapi.microsoft.com"
xmlns:q9="https://adapi.microsoft.com"
xmlns:q10="https://adapi.microsoft.com"
xmlns:q11="https://adapi.microsoft.com"
xmlns:q12="https://adapi.microsoft.com"
xmlns:q13="https://adapi.microsoft.com"
xmlns:q14="https://adapi.microsoft.com"
xmlns:q15="https://adapi.microsoft.com"
xmlns:q16="https://adapi.microsoft.com"
xmlns:q17="https://adapi.microsoft.com"
xmlns:q18="https://adapi.microsoft.com"
xmlns:q19="https://adapi.microsoft.com"
xmlns:q20="https://adapi.microsoft.com"
xmlns:q21="https://adapi.microsoft.com"
xmlns:q22="https://adapi.microsoft.com"
xmlns:q23="https://adapi.microsoft.com"
xmlns:q24="https://adapi.microsoft.com"
xmlns:q25="https://adapi.microsoft.com"
xmlns:q26="https://adapi.microsoft.com"
xmlns:q27="https://adapi.microsoft.com"
xmlns:q28="https://adapi.microsoft.com"
xmlns:q29="https://adapi.microsoft.com"
xmlns:q30="https://adapi.microsoft.com"
xmlns:q31="https://adapi.microsoft.com"
xmlns:q32="https://adapi.microsoft.com"
xmlns:q33="https://adapi.microsoft.com"
xmlns:q34="https://adapi.microsoft.com"
xmlns:q35="https://adapi.microsoft.com"
xmlns:q36="https://adapi.microsoft.com"
xmlns:q37="https://adapi.microsoft.com">
<soap:Header>
<tns:Action>GetAccountsInfo</tns:Action>
<tns:ApplicationToken>actual_token</tns:ApplicationToken>
<tns:AuthenticationToken>actual_token</tns:AuthenticationToken>
<tns:DeveloperToken>actual_token</tns:DeveloperToken>
</soap:Header>
<soap:Body>
<GetAccountsInfoRequest
xmlns="https://bingads.microsoft.com/Customer/v13" xsi:nil="true">
</GetAccountsInfoRequest>
</soap:Body>
</soap:Envelope>
I also output the URL:
https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/V13/CustomerManagementService.svc?wsdl
When I copy these into Postman/Insomia/other API clients I get a 200 OK response BUT not the data I need. The returned XML is 1000s of lines of what looks like the API (Microsoft/Bing Ads API for their customer management service) definition.
I assume it's telling me that the request is wrong, so here, take a guide. But I don't know where to begin looking.
Anything I should look out for when translating Nodes' soap package -> a SOAP call within Postman?

Getting xop include object using nodejs

I need to download the xop include object which is coming in response of one SOAP service using NodeJS.
I am able to get the response using soap library, but need to understand how to download the file
<ns2:result xsi:type="ns0:DocumentDetails" xmlns:ns2="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/types/" xmlns:ns1="http://xmlns.oracle.com/adf/svc/types/" xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:Content>
<xop:Include href="cid:3418224f-0d44-4e65-a8fb-a2f8bfb3b87d" xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
</ns0:Content>
<ns0:FileName xsi:nil="true"/>
<ns0:ContentType xsi:nil="true"/>
<ns0:DocumentTitle>TEST.pdf</ns0:DocumentTitle>
<ns0:DocumentAuthor>testAuthor</ns0:DocumentAuthor>
<ns0:DocumentSecurityGroup>Attachments</ns0:DocumentSecurityGroup>
<ns0:DocumentAccount xsi:nil="true"/>
<ns0:DocumentName>Test.pdf</ns0:DocumentName>
<ns0:DocumentId>11758236</ns0:DocumentId>
</ns2:result>
</ns0:getDocumentForDocumentIdResponse>

Can't remove email address from EWS contact

I'm using the ews-javascript-api to manage my EWS contacts on an exchange server.
I'm trying to update a contact object by removing an email address.
I've followed this blog post and it's got me most of the way there. However, when I remove the ExtendedProperty's for EmailAddress1 the ews-javascript-api throws an exception due to an HTTP 500 coming back from the EWS soap request to update a contact. Looking at the SOAP request, I can see that there is an empty FieldURI which is what the response error is complaining about.
Here is my soap request
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2"></t:RequestServerVersion>
</soap:Header>
<soap:Body>
<m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AutoResolve">
<m:ItemChanges>
<t:ItemChange>
<t:ItemId Id="AAMkADczNzM2MTM4LTZmNWItNDBhYy05ZjcwLWUxMDc3ZDY2NjFiMABGAAAAAAC3bTmWRbrTRqYt+VZXGp68BwD5r6sZ7j5YSprMfvM2gaMkAAAAAAAQAAD5r6sZ7j5YSprMfvM2gaMkAAB4CjURAAA=" ChangeKey="EQAAABYAAAD5r6sZ7j5YSprMfvM2gaMkAAB4CkS4"></t:ItemId>
<t:Updates>
<t:SetItemField>
<t:FieldURI FieldURI="contacts:DisplayName"></t:FieldURI>
<t:Contact>
<t:DisplayName>Craig </t:DisplayName>
</t:Contact>
</t:SetItemField>
<t:SetItemField>
<t:FieldURI FieldURI="contacts:GivenName"></t:FieldURI>
<t:Contact>
<t:GivenName>Craig</t:GivenName>
</t:Contact>
</t:SetItemField>
<t:DeleteItemField>
<t:FieldURI></t:FieldURI>
</t:DeleteItemField>
<t:DeleteItemField>
<t:FieldURI FieldURI="contacts:MiddleName"></t:FieldURI>
</t:DeleteItemField>
<t:DeleteItemField>
<t:FieldURI FieldURI="contacts:Surname"></t:FieldURI>
</t:DeleteItemField>
</t:Updates>
</t:ItemChange>
</m:ItemChanges>
</m:UpdateItem>
</soap:Body>
And here is the soap response
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode
xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorSchemaValidation
</faultcode>
<faultstring xml:lang="en-US">The request failed schema validation: The required attribute 'FieldURI' is missing.</faultstring>
<detail>
<e:ResponseCode
xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorSchemaValidation
</e:ResponseCode>
<e:Message
xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The request failed schema validation.
</e:Message>
<t:MessageXml
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<t:LineNumber>1</t:LineNumber>
<t:LinePosition>1037</t:LinePosition>
<t:Violation>The required attribute 'FieldURI' is missing.</t:Violation>
</t:MessageXml>
</detail>
</s:Fault>
</s:Body>
And finally here is the exception that the javascript api throws.
"Exception
at UpdateItemRequest../node_modules/ews-javascript-api/js/Core/Requests/ServiceRequestBase.js.ServiceRequestBase.ProcessWebException (https://sr1.genband.com/genlync/bundle-electron.js:44707:36)
at https://sr1.genband.com/genlync/bundle-electron.js:45557:41
at <anonymous>"
Finally I'll mention that I can remove an email address without removing any extended properties with the following function.
response.EmailAddresses._setItem(ews.EmailAddressKey.EmailAddress1, address.value);
However, the problem with this is, while it looks like it works, if I try to edit that contact on my outlook web interface, I get an error about some property mismatch. Looks like if I don't remove those extended properties when deleting an email, then they stay around and cause issues for other clients.
this should work in 0.9.3 version, available starting 0.9.3-dev.1 which is ews-javascript-api#next currently.

Invalid XML feed from DocuSign Connect

When using Connect to receive a docusign envelope via a web service we have received invalid XML for one of our envelopes. Personal data and PDFBytes have been removed from this copy.
<?xml version="1.0" encoding="utf-8"?><DocuSignEnvelopeInformation xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.docusign.net/API/3.0"><EnvelopeStatus><RecipientStatuses><RecipientStatus><Type>Signer</Type><Email>#ymail.com</Email><UserName>o</UserName><RoutingOrder>1</RoutingOrder><Sent>2013-07-03T13:36:59.257</Sent><Delivered>2013-07-04T09:35:13.23</Delivered><Signed>2013-07-04T10:01:21.447</Signed><DeclineReason xsi:nil="true" /><Status>Completed</Status><RecipientIPAddress>_</RecipientIPAddress><CustomFields /><TabStatuses><TabStatus><TabType>Custom</TabType><Status>Signed</Status><XPosition>927</XPosition><YPosition>1162</YPosition><TabLabel>SSN</TabLabel><TabName>SSN</TabName><TabValue>_</TabValue><DocumentID>1</DocumentID><PageNumber>1</PageNumber><ValidationPattern /><CustomTabType>SSN</CustomTabType></TabStatus><TabStatus><TabType>FirstName</TabType><Status>Signed</Status><XPosition>100</XPosition><YPosition>1166</YPosition><TabLabel>First Name</TabLabel><TabName>First Name</TabName><TabValue>_</TabValue><DocumentID>1</DocumentID><PageNumber>1</PageNumber></TabStatus><TabStatus><TabType>LastName</TabType><Status>Signed</Status><XPosition>462</XPosition><YPosition>1166</YPosition><TabLabel>Last Name</TabLabel><TabName>Last Name</TabName><TabValue>_</TabValue><DocumentID>1</DocumentID><PageNumber>1</PageNumber></TabStatus><TabStatus><TabType>Custom</TabType><Status>Signed</Status><XPosition>1072</XPosition><YPosition>1291</YPosition><TabLabel>Data Field 5</TabLabel><TabName>Text</TabName><TabValue>1</TabValue><DocumentID>1</DocumentID><PageNumber>1</PageNumber><ValidationPattern /><CustomTabType>Text</CustomTabType></TabStatus><TabStatus><TabType>Custom</TabType><Status>Signed</Status><XPosition>664</XPosition><YPosition>1193</YPosition><TabLabel>Exemptions</TabLabel><TabName>Single</TabName><TabValue>X</TabValue><DocumentID>1</DocumentID><PageNumber>1</PageNumber><ValidationPattern /><CustomTabType>Radio</CustomTabType></TabStatus><TabStatus><TabType>SignHere</TabType><Status>Signed</Status><XPosition>406</XPosition><YPosition>1420</YPosition><TabLabel>Signature 9</TabLabel><TabName>Sign Here</TabName><TabValue /><DocumentID>1</DocumentID><PageNumber>1</PageNumber></TabStatus><TabStatus><TabType>Custom</TabType><Status>Active</Status><XPosition>756</XPosition><YPosition>1193</YPosition><TabLabel>Exemptions</TabLabel><TabName>Married</TabName><TabValue /><DocumentID>1</DocumentID><PageNumber>1</PageNumber><ValidationPattern /><CustomTabType>Radio</CustomTabType></TabStatus><TabStatus><TabType>Custom</TabType><Status>Active</Status><XPosition>845</XPosition><YPosition>1193</YPosition><TabLabel>Exemptions</TabLabel><TabName>Married but Single</TabName><TabValue /><DocumentID>1</DocumentID><PageNumber>1</PageNumber><ValidationPattern /><CustomTabType>Radio</CustomTabType></TabStatus><TabStatus><TabType>Custom</TabType><Status>Active</Status><XPosition>100</XPosition><YPosition>1208</YPosition><TabLabel>Address</TabLabel><TabName>Address Line 1</TabName><TabValue /><DocumentID>1</DocumentID><PageNumber>1</PageNumber><ValidationPattern /><CustomTabType>Text</CustomTabType></TabStatus><TabStatus><TabType>DateSigned</TabType><Status>Signed</Status><XPosition>989</XPosition><YPosition>1493</YPosition><TabLabel>Date Signed</TabLabel><TabName>Date Signed</TabName><TabValue>7/4/2013 </TabValue><DocumentID>1</DocumentID><PageNumber>1</PageNumber></TabStatus></TabStatuses><RecipientAttachment><Attachment><Data>_</Data><Label>DSXForm</Label><Type>.xml</Type></Attachment></RecipientAttachment><AccountStatus>Active</AccountStatus><EsignAgreementInformation><AccountEsignId>79e2c3d5-971c-4e7b-8b34-575e21896435</AccountEsignId><UserEsignId>ae45b756-aa08-44d6-bc46-be76ed123a5a</UserEsignId><AgreementDate>2013-07-04T09:35:13.213</AgreementDate></EsignAgreementInformation><FormData><xfdf><fields><field name="SSN"><value>_</value></field><field name="FirstName"><value>_</value></field><field name="LastName"><value>_</value></field><field name="Data Field 5"><value>1</value></field><field name="Exemptions"><value>Single</value></field><field name="Address"><value /></field><field name="DateSigned"><value>7/4/2013 </value></field></fields></xfdf></FormData><RecipientId>1c70c533-4787-4ed2-8d0f-3b56e5bad87a</RecipientId></RecipientStatus></RecipientStatuses><TimeGenerated>2013-07-09T07:02:59.5158647</TimeGenerated><EnvelopeID>daff200b-0d82-480a-83d1-e253d50e4cbb</EnvelopeID><Subject>_</Subject><UserName>_</UserName><Email>_</Email><Status>Completed</Status><Created>2013-07-03T13:36:58.523</Created><Sent>2013-07-03T13:36:59.303</Sent><Delivered>2013-07-04T09:35:13.323</Delivered><Signed>2013-07-04T10:01:21.507</Signed><Completed>2013-07-04T10:01:21.507</Completed><ACStatus>Original</ACStatus><ACStatusDate>2013-07-03T13:36:58.523</ACStatusDate><ACHolder>Onboarding</ACHolder><ACHolderEmail>_</ACHolderEmail><ACHolderLocation>DocuSign</ACHolderLocation><SigningLocation>Online</SigningLocation><SenderIPAddress>_</SenderIPAddress><EnvelopePDFHash /><CustomFields><CustomField><Name>taskId</Name><Show>True</Show><Required>True</Required><Value>CDFA8755-1FE4-E211-80E5-005056A930BA</Value></CustomField></CustomFields><AutoNavigation>true</AutoNavigation><EnvelopeIdStamping>true</EnvelopeIdStamping><AuthoritativeCopy>false</AuthoritativeCopy><DocumentStatuses><DocumentStatus><ID>1</ID><Name>fw4.pdf</Name><TemplateName>W4</TemplateName><Sequence>1</Sequence></DocumentStatus></DocumentStatuses></EnvelopeStatus><DocumentPDFs><DocumentPDF><Name>fw4.pdf</Name><PDFBytes>_____________________________________________________________</PDFBytes><DocumentType>CONTENT</DocumentType></DocumentPDF></DocumentPDFs></DocuSignEnvelopeInformation>_____________________________________________________________</PDFBytes><DocumentType>CONTENT</DocumentType></DocumentPDF></DocumentPDFs></DocuSignEnvelopeInformation>
The errror is after the first closing tag, additional (different) PDFBytes and tags are given.
Why is data sent after the closing DocuSignEnvelopeInformation tag?
Republishing the XML for this envelope should help determine if it was a one off or if there's a bug with the Connect service. You should be able to republish the XML through your DocuSign Console settings, if you do that do you still get malformed XML?

Possible to upload a public GoogleDoc using Google Docs List API?

I am creating a web app where I would like the user to be able to manipulate contents of a spreadsheet that do not get saved to the original spreadsheet-- in effect so that multiple users can access the same spreadsheet and the data/formulas contained without interfering with one another.
If my spreadsheet is public, is there a way for users to upload it programmatically using the docs list API? That way they have a copy saved where they can make whatever changes desired.
Thank you!
You can copy a spreadsheet by issuing a POST request as documented here:
POST https://docs.google.com/feeds/default/private/full
Authorization: <your authorization header here>
Content-Type: application/atom+xml
[Additional headers]
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
<id>[SELF_LINK_OF_THE_ORIGINAL_DOCUMENT]</id>
<title>My Copy</title>
</entry>

Resources