PayPal API using SOAP - api

I need to use the PayPal API, using SOAP, to get our PayPal balance.
I've got as far as making a request using this XML:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
<SOAP-ENV:Header>
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
<Username>[xxxxx]</Username>
<Password>[xxxxx]</Password>
<Signature>[xxxxx]</Signature>
<Subject>
</Subject>
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<GetBalanceReq xsi:type="GetBalanceRequest">
<GetBalanceRequest xsi:type="GetBalanceRequestType">
<Version>83.0</Version>
<ReturnAllCurrencies>0</ReturnAllCurrencies>
</GetBalanceRequest>
</GetBalanceReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
...but I'm getting this response:
SOAP-ENV:ClientMethod 'GetBalanceReq' not implemented
Does my XML look ok..?

You can omit the optional parts in the "Credentials" header. Maybe you did not select the right endpoint (it seems getBalance is not available). The following SOAP request works with the latest sandbox WSDL :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ebay:api:PayPalAPI" xmlns:urn1="urn:ebay:apis:eBLBaseComponents">
<soapenv:Header>
<urn:RequesterCredentials>
<urn1:Credentials>
<urn1:Username>xxxx</urn1:Username>
<urn1:Password>xxxx</urn1:Password>
<urn1:Signature>xxxx</urn1:Signature>
</urn1:Credentials>
</urn:RequesterCredentials>
</soapenv:Header>
<soapenv:Body>
<urn:GetBalanceReq>
<urn:GetBalanceRequest>
<urn1:Version>83.0</urn1:Version>
<urn:ReturnAllCurrencies>0</urn:ReturnAllCurrencies>
</urn:GetBalanceRequest>
</urn:GetBalanceReq>
</soapenv:Body>
</soapenv:Envelope>
And the response:
<SOAP-ENV:Envelope "...">
<SOAP-ENV:Header>
"..."
</SOAP-ENV:Header>
<SOAP-ENV:Body id="_0">
<GetBalanceResponse xmlns="urn:ebay:api:PayPalAPI">
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2011-10-20T17:27:54Z</Timestamp>
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Success</Ack>
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">e6bb1ac6861d7</CorrelationID>
<Version xmlns="urn:ebay:apis:eBLBaseComponents">83.0</Version>
<Build xmlns="urn:ebay:apis:eBLBaseComponents">2183220</Build>
<Balance xsi:type="cc:BasicAmountType" currencyID="USD">0.00</Balance>
<BalanceTimeStamp xsi:type="xs:dateTime">2011-10-20T17:27:54Z</BalanceTimeStamp>
</GetBalanceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Related

How to write SQL inside XML SOAP request - salesforce marketing cloud API

I am new to SOAP.
I am trying to get the Send Object information and I am able to pull all the data I need except
SendID
This is the request I make in postman
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<fueloauth>{{sf_ps_access_token}}</fueloauth>
</soapenv:Header>
<soapenv:Body>
<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<RetrieveRequest>
<ObjectType>Send</ObjectType>
<Properties>ID</Properties>
<Properties>BCCEmail</Properties>
<Properties>SendID</Properties>
<Properties>Client.PartnerClientKey</Properties>
<Properties>PartnerKey</Properties>
<Properties>CreatedDate</Properties>
<Properties>ModifiedDate</Properties>
<Properties>Client.ID</Properties>
<Properties>Email.ID</Properties>
<Properties>Email.PartnerKey</Properties>
<Properties>SendDate</Properties>
<Properties>FromAddress</Properties>
<Properties>FromName</Properties>
<Properties>Duplicates</Properties>
<Properties>InvalidAddresses</Properties>
<Properties>HardBounces</Properties>
<Properties>SoftBounces</Properties>
<Properties>OtherBounces</Properties>
<Properties>ForwardedEmails</Properties>
<Properties>UniqueClicks</Properties>
<Properties>UniqueOpens</Properties>
<Properties>NumberSent</Properties>
<Properties>NumberDelivered</Properties>
<Properties>NumberTargeted</Properties>
<Properties>NumberErrored</Properties>
<Properties>NumberExcluded</Properties>
<Properties>Unsubscribes</Properties>
<Properties>MissingAddresses</Properties>
<Properties>Subject</Properties>
<Properties>PreviewURL</Properties>
<Properties>SentDate</Properties>
<Properties>EmailName</Properties>
<Properties>Status</Properties>
<Properties>EmailSendDefinition.ObjectID</Properties>
<Properties>EmailSendDefinition.CustomerKey</Properties>
<Properties>Client.PartnerClientKey</Properties>
<Properties>Email.PartnerKey</Properties>
<Filter xsi:type="ns1:SimpleFilterPart" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
<Property>CreatedDate</Property>
<SimpleOperator>between</SimpleOperator>
<DateValue>2018-01-01</DateValue>
<DateValue>2021-12-09</DateValue>
</Filter>
</RetrieveRequest>
</RetrieveRequestMsg>
</soapenv:Body>
</soapenv:Envelope>
This is the error I am getting:
Error: Column 'dbo.tblJobs.SendID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
How do I write SQL inside the xml SOAP request?
My response on this one is late. I think the problem is ,
In Send object (<ObjectType>Send</ObjectType>) there is no field as SendID. If you need Job Id inorder to connect other tracking, you need to use "ID" attribute. You can further improve using BatchId
SendID is present in other event like clicks or open. You can use SendId in those event for filtering the data
Sample message for getting send info :
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">Retrieve</a:Action>
<a:To s:mustUnderstand="1">https://{{et_subdomain}}.soap.marketingcloudapis.com/Service.asmx</a:To>
<fueloauth xmlns="http://exacttarget.com">{{AccessToken}}</fueloauth>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<Options>
</Options>
<RetrieveRequest>
<ObjectType>Send</ObjectType>
<Properties>Client.ID</Properties>
<Properties>Email.ID</Properties>
<Properties>EmailName</Properties>
<Properties>Subject</Properties>
<Properties>SendDate</Properties>
<Properties>CreatedDate</Properties>
<Properties>Status</Properties>
<Properties>FromAddress</Properties>
<Properties>FromName</Properties>
<Properties>ID</Properties>
<Properties>NumberSent</Properties>
<Properties>NumberDelivered</Properties>
<Properties>ForwardedEmails</Properties>
<Properties>NumberErrored</Properties>
<Properties>NumberExcluded</Properties>
<Properties>ExistingUndeliverables</Properties>
<Properties>ExistingUnsubscribes</Properties>
<Properties>SoftBounces</Properties>
<Properties>HardBounces</Properties>
<Properties>OtherBounces</Properties>
<Properties>Unsubscribes</Properties>
<Properties>UniqueOpens</Properties>
<Properties>UniqueClicks</Properties>
<Properties>PreviewURL</Properties>
<Filter xsi:type="ns1:SimpleFilterPart" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
<Property>ID</Property>
<SimpleOperator>between</SimpleOperator>
<Value>1</Value><Value>10000</Value>
</Filter>
</RetrieveRequest>
</RetrieveRequestMsg>
</s:Body>
</s:Envelope>
Once you have the JobId(ID) from above , you can use it to get other tracking .
Using the job Id to get all related sent tracking :
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">Retrieve</a:Action>
<a:To s:mustUnderstand="1">https://{{et_subdomain}}.soap.marketingcloudapis.com/Service.asmx</a:To>
<fueloauth xmlns="http://exacttarget.com">{{AccessToken}}</fueloauth>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<Options>
</Options>
<RetrieveRequest>
<ObjectType>SentEvent</ObjectType>
<Properties>Client.ID</Properties>
<Properties>SubscriberKey</Properties>
<Properties>EventDate</Properties>
<Properties>SendID</Properties>
<Properties>BatchID</Properties>
<Filter xsi:type="ns1:SimpleFilterPart" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
<Property>SendID</Property>
<SimpleOperator>between</SimpleOperator>
<Value>1</Value><Value>9000</Value>
</Filter>
</RetrieveRequest>
</RetrieveRequestMsg>
</s:Body>
</s:Envelope>

SQL Parse soap xml and show as a string

I am trying to return the ErrorReason from the below soap xml response. However it keeps returning empty. I am not sure how to handle the namespace.
I expect to return "The specified envelope has duplicate recipients."
declare #xml xml =
(
'<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" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsa:Action>http://schemas.xmlsoap.org/ws/2004/08/addressing/fault</wsa:Action>
<wsa:MessageID>urn:uuid:b0c43031-35b9-40a1-a217-36491cfdd07c</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:4871a441-ea1e-4f9b-953b-d3f426674597</wsa:RelatesTo>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-c41a3e0c-317d-46e2-b203-6a0a43450313">
<wsu:Created>2017-08-31T18:11:00Z</wsu:Created>
<wsu:Expires>2017-08-31T18:16:00Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>The specified envelope has duplicate recipients. </faultstring>
<faultactor>https://www.test.asmx</faultactor>
<detail>
<ErrorCode xmlns="missing in Web.Config">140</ErrorCode>
<ErrorReason xmlns="missing in Web.Config">The specified envelope has duplicate recipients.</ErrorReason>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>'
)
select x.value('ErrorReason[1]','VARCHAR(max)') from #xml.nodes('/*:Envelope/*:Body/detail') as X(x)
you want the below query
select #xml.query('/*:Envelope/*:Body/*:Fault/*:detail/*:ErrorReason/text()')

Why does .NET XMLSerializer automatically change my namespace prefixes (alias)?

I am working on a web service that needs to return faults in a way that is defined by the standards of our type of business. This requires me to return a fault as this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<Timestamp xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" />
</wsse:Security>
</soap:Header>
<soap:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Fault>
<faultcode>s:Server</faultcode>
<faultstring>Operator/operand type mismatch.</faultstring>
<faultactor>urn:dealernumberID:??????</faultactor>
<detail>
<ErrorType xmlns="http://www.starstandards.org/webservices/2009/transport">Backend Client Fault</ErrorType>
<ErrorDetail xmlns="http://www.starstandards.org/webservices/2009/transport">Backend client returned a fault</ErrorDetail>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I create the fault like this, but when the service sends it, it looks like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<Timestamp xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" />
</h:Security>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<s:Fault>
<faultcode>s:Server</faultcode>
<faultstring>Operator/operand type mismatch.</faultstring>
<faultactor>urn:dealernumberID:??????</faultactor>
<detail>
<ErrorType xmlns="http://www.starstandards.org/webservices/2009/transport">Backend Client Fault</ErrorType>
<ErrorDetail xmlns="http://www.starstandards.org/webservices/2009/transport">Backend client returned a fault</ErrorDetail>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
Why does this happen? Is there a setting that I can change in .NET to keep it from doing this by default? I do understand that a namespace is a namespace regardless of the prefix, but like I said, the standard dictates we do it a certain way (most likely to accommodate third parties that are reading responses as strings?)
Thanks for any help!

Is there some example xml for the FormInfo list for the updateCredentialsForItem1?

I have been receiving the following error when trying to post updated login credentials:
<Exception>org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Can not invoke the getTypeObject method in the extension mapper class...
I am accessing the SOAP API via a rails app using the savon gem.
addItemForContentService is working with the same xsi:type definition, and I have used getLoginFormCredentialsForItem to retrieve FormInfos to push back into updateCredentialsForItem1, with no success.
If I could just get some sample xml (that works) for this call I would really appreciate it.
It seems like the parameters you are sending are incorrect or the WSDL format.
For your reference below is XML for updateCredentialsForItem1(you need to change values):
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<updateCredentialsForItem1 xmlns="http://itemmanagement.accountmanagement.core.soap.yodlee.com">
<userContext xmlns="">
<cobrandId>134131232</cobrandId>
<channelId>-1</channelId>
<locale>
<country>US</country>
<language>en</language>
<variant></variant>
</locale>
<tncVersion>2</tncVersion>
<applicationId>7A367HGJ621219F00</applicationId>
<cobrandConversationCredentials xsi:type="ns1:SessionCredentials" xmlns:ns1="http://login.ext.soap.yodlee.com">
<sessionToken>YOUR_COBRAND_CONVERSATION_TOKEN_VALUE</sessionToken>
</cobrandConversationCredentials>
<preferenceInfo>
<currencyCode>USD</currencyCode>
<timeZone>PST</timeZone>
<dateFormat>MM/dd/yyyy</dateFormat>
<currencyNotationType>SYMBOL_NOTATION</currencyNotationType>
<numberFormat>
<decimalSeparator>.</decimalSeparator>
<groupingSeparator>,</groupingSeparator>
<groupPattern>###,##0.##</groupPattern>
</numberFormat>
</preferenceInfo>
<fetchAllLocaleData>false</fetchAllLocaleData>
<conversationCredentials xsi:type="ns2:SessionCredentials" xmlns:ns2="http://login.ext.soap.yodlee.com">
<sessionToken>USER_CONVERSATION_TOKEN_VALUE</sessionToken>
</conversationCredentials>
<valid>true</valid>
<isPasswordExpired>false</isPasswordExpired>
</userContext>
<itemId xmlns="">1219123123</itemId>
<credentialFields xmlns="">
<elements xsi:type="ns3:SecureFieldInfoSingle" xmlns:ns3="http://common.soap.yodlee.com">
<name>LOGIN</name>
<displayName>Username</displayName>
<isEditable>true</isEditable>
<isOptional>false</isOptional>
<isEscaped>false</isEscaped>
<helpText>2212059</helpText>
<isOptionalMFA>false</isOptionalMFA>
<isMFA>false</isMFA>
<value>ACTUAL_USERNAME</value>
<valueIdentifier>LOGIN</valueIdentifier>
<valueMask>LOGIN_FIELD</valueMask>
<fieldType>TEXT</fieldType>
<size>20</size>
<maxlength>40</maxlength>
</elements>
<elements xsi:type="ns4:SecureFieldInfoSingle" xmlns:ns4="http://common.soap.yodlee.com">
<name>PASSWORD1</name>
<displayName>Password</displayName>
<isEditable>true</isEditable>
<isOptional>false</isOptional>
<isEscaped>false</isEscaped>
<helpText>22121258</helpText>
<isOptionalMFA>false</isOptionalMFA>
<isMFA>false</isMFA>
<value>ACTUAL_PASSWORD_VALUE</value>
<valueIdentifier>PASSWORD1</valueIdentifier>
<valueMask>LOGIN_FIELD</valueMask>
<fieldType>PASSWORD</fieldType>
<size>20</size>
<maxlength>40</maxlength>
</elements>
<elements xsi:type="ns5:FieldInfoSingle" xmlns:ns5="http://common.soap.yodlee.com">
<name></name>
<displayName>Verify Password</displayName>
<isEditable>true</isEditable>
<isOptional>false</isOptional>
<isEscaped>false</isEscaped>
<helpText>22121258</helpText>
<isOptionalMFA>false</isOptionalMFA>
<isMFA>false</isMFA>
<value>ACTUAL_PASSWORD_VALUE</value>
<valueIdentifier>PASSWORD1</valueIdentifier>
<valueMask>LOGIN_FIELD</valueMask>
<fieldType>PASSWORD</fieldType>
<size>20</size>
<maxlength>40</maxlength>
</elements>
</credentialFields>
<startRefreshItemOnUpdate xmlns="">false</startRefreshItemOnUpdate>
</updateCredentialsForItem1>
</soapenv:Body>
</soapenv:Envelope>

How to hold Soap sessionid when calling another method in Objective-C

I'm trying to do some calls to webservices, but when I change the method the sessionId is different from the last method called. So I want to hold the session. I've tried many ways with no result. I am almost sure that I have to pass the session in SoapHeader method, like this:
<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/" xmlns="http://xxx">
<soap:Header>
<SessionHeader xmlns='http://xxx'>
<sessionId>jsessionid=ABCDEFGHI:-1</sessionId>
</SessionHeader>
</soap:Header>
With no Result...
<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<p118:method1:p118="http://xxx">
In the second method, the sessionId is a new session:
<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<p118:method2 xmlns:p118="http://xxx">
How can i do this? Thank you very much!