org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: '<?xml version="1.0" encoding="UTF-8"? - scribe

I am getting the following exception when I use scribe library for posting image to twitter
org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: '<?xml version="1.0" encoding="UTF-8"?
I am using scribe1.3.3 library.
I searched in google for this Exception ,but didnt find any solution.
Source Code:
OAuthService oAuth = new ServiceBuilder()
.provider(TwitterApi.class)
.apiKey("6JyIkj71ZqG4wk3YF0Y4hw") // REPLACE WITH YOUR OWN!!!
.apiSecret("sJl9aRVqlEt7nxlKvpMVK6tLULz5FSQ2KUOW0yie4") // REPLACE WITH YOUR OWN!!!
.callback(TwitterDialog.redirectedurl) // REPLACE WITH YOUR OWN!!!
.build();
Uri uri = Uri.parse(TwitterDialog.redirectedurl);
Token requestToken = new Token( uri.getQueryParameter("oauth_token"),uri.getQueryParameter("oauth_verifier"));
Verifier verifier = new Verifier(uri.getQueryParameter("oauth_verifier"));
if(verifier!=null){
Log.e("verifier created","created");
}
Token accesstoken=oAuth.getAccessToken(requestToken, verifier);
Log.e("raw resp", accesstoken.getRawResponse());
if(accesstoken!=null){
Log.e("hello","hhello");
Log.e("access token","hi"+accesstoken.toString());
OAuthRequest request = new OAuthRequest(Verb.POST, "https://upload.twitter.com/1/statuses/update_with_media.json");
oAuth.signRequest(accesstoken, request); // ENTER USER'S ACCESS TOKEN
// ADD MULTIPART FORM
try
{
MultipartEntity entity = new MultipartEntity();
entity.addPart("status", new StringBody("insert vacuous statement here")); // THIS IS THE TWITTER MESSAGE
entity.addPart("media", new FileBody(new File("/storage/sdcard0/HelloAlbum/1361964305003.jpg"))); // THIS IS THE PHOTO TO UPLOAD
ByteArrayOutputStream out = new ByteArrayOutputStream();
entity.writeTo(out);
request.addPayload(out.toByteArray());
request.addHeader(entity.getContentType().getName(), entity.getContentType().getValue());
}
catch (UnsupportedEncodingException e) {e.printStackTrace();}
catch (IOException e) {e.printStackTrace();}
// SEND REQUEST
try {JSONObject response = new JSONObject (request.send().getBody());}
catch (JSONException e) {Log.e("TOUR_APP_TAG", "JSONException Thrown: " + e.getMessage());}
}
Logcat output:
03-05 15:52:24.810: E/AndroidRuntime(28777): FATAL EXCEPTION: main
03-05 15:52:24.810: E/AndroidRuntime(28777): org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: '<?xml version="1.0" encoding="UTF-8"?>
03-05 15:52:24.810: E/AndroidRuntime(28777): <hash>
03-05 15:52:24.810: E/AndroidRuntime(28777): <request>/oauth/access_token</request>
03-05 15:52:24.810: E/AndroidRuntime(28777): <error>Invalid / expired Token</error>
03-05 15:52:24.810: E/AndroidRuntime(28777): </hash>
03-05 15:52:24.810: E/AndroidRuntime(28777): '
03-05 15:52:24.810: E/AndroidRuntime(28777): at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:41)
03-05 15:52:24.810: E/AndroidRuntime(28777): at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:27)
03-05 15:52:24.810: E/AndroidRuntime(28777): at org.scribe.oauth.OAuth10aServiceImpl.getAccessToken(OAuth10aServiceImpl.java:103)
03-05 15:52:24.810: E/AndroidRuntime(28777): at org.scribe.oauth.OAuth10aServiceImpl.getAccessToken(OAuth10aServiceImpl.java:84)
03-05 15:52:24.810: E/AndroidRuntime(28777): at org.scribe.oauth.OAuth10aServiceImpl.getAccessToken(OAuth10aServiceImpl.java:89)
03-05 15:52:24.810: E/AndroidRuntime(28777): at com.android.twitter.TwitterActivity$1.onComplete(TwitterActivity.java:317)
03-05 15:52:24.810: E/AndroidRuntime(28777): at com.twitter.android.TwitterApp$1.handleMessage(TwitterApp.java:236)
03-05 15:52:24.810: E/AndroidRuntime(28777): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 15:52:24.810: E/AndroidRuntime(28777): at android.os.Looper.loop(Looper.java:137)
03-05 15:52:24.810: E/AndroidRuntime(28777): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-05 15:52:24.810: E/AndroidRuntime(28777): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 15:52:24.810: E/AndroidRuntime(28777): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 15:52:24.810: E/AndroidRuntime(28777): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-05 15:52:24.810: E/AndroidRuntime(28777): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-05 15:52:24.810: E/AndroidRuntime(28777): at dalvik.system.NativeStart.main(Native Method)

Related

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()')

Post-installation issue in Cordys

I am new to Cordys, I am facing the stated issue and have tried everything suggested in the installation guide of CARS 2.4 and Cordys BOP 4.3.
The following post-installation issue is coming:
<ErrorDetails>
<Request>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<GetUserDetails xmlns="http://schemas.cordys.com/1.0/ldap"/>
</SOAP:Body>
</SOAP:Envelope>
</Request>
<Response>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<SOAP:Fault>
<faultcode xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/">ns0:Server</faultcode>
<faultstring xml:lang="en-US">Communication Failure.</faultstring>
<faultactor>com.eibus.web.soap.Gateway.wcp</faultactor>
<detail>
<cordys:FaultDetails xmlns:cordys="http://schemas.cordys.com/General/1.0/">
<cordys:LocalizableMessage xmlns:cordys="http://schemas.cordys.com/General/1.0/">
<cordys:MessageCode xmlns:cordys="http://schemas.cordys.com/General/1.0/">Cordys.WebGateway.Messages.CommunicationError</cordys:MessageCode>
</cordys:LocalizableMessage>
</cordys:FaultDetails>
<cordys:FaultRelatedException xmlns:cordys="http://schemas.cordys.com/General/1.0/">LDAPException: (40) Failed to send message to [cn=LDAP,cn=soap nodes,o=system,cn=cordys,cn=cordys_43,o=ADNATEITSOLUTIONS.COM]. [com.eibus.exception.BusException: No SOAPProcessor available for: cn=LDAP,cn=soap nodes,o=system,cn=cordys,cn=cordys_43,o=ADNATEITSOLUTIONS.COM] LDAPException: Server Message: Failed to send message to [cn=LDAP,cn=soap nodes,o=system,cn=cordys,cn=cordys_43,o=ADNATEITSOLUTIONS.COM]. [com.eibus.exception.BusException: No SOAPProcessor available for: cn=LDAP,cn=soap nodes,o=system,cn=cordys,cn=cordys_43,o=ADNATEITSOLUTIONS.COM] at com.eibus.directory.soap.LDAPSearchCache.search(LDAPSearchCache.java:466) at com.eibus.directory.soap.LDAPSearchCache.loadCacheValueInternal(LDAPSearchCache.java:235) at com.eibus.util.cache.Cache.loadCacheValue(Cache.java:421) at com.eibus.util.cache.Cache.get(Cache.java:278) at com.eibus.directory.soap.LDAPSearchCache.getLDAPResults(LDAPSearchCache.java:323) at com.eibus.directory.soap.Cache.search(Cache.java:366) at com.eibus.directory.soap.Cache.search(Cache.java:334) at com.eibus.directory.soap.Cache.read(Cache.java:430) at com.eibus.directory.soap.Proxy.read(Proxy.java:458) at com.eibus.directory.soap.LDAPDirectory.read(LDAPDirectory.java:902) at com.eibus.directory.soap.LDAPDirectory.getEntry(LDAPDirectory.java:623) at com.eibus.directory.soap.LDAPDirectory.getURIs(LDAPDirectory.java:639) at com.eibus.transport.Middleware.getInboundURIs(Middleware.java:531) at com.eibus.transport.Middleware.<init>(Middleware.java:199) at com.eibus.transport.Middleware.getInstance(Middleware.java:140) at com.eibus.transport.Middleware.getInstance(Middleware.java:126) at com.eibus.web.gateway.BusGateway.<init>(BusGateway.java:172) at com.eibus.web.gateway.BusGateway.<init>(BusGateway.java:72) at com.eibus.web.gateway.BusGateway.getGateway(BusGateway.java:66) at com.eibus.web.gateway.SOAPTransaction.createConnection(SOAPTransaction.java:1279) at com.eibus.web.gateway.SOAPTransaction.<init>(SOAPTransaction.java:218) at com.eibus.web.gateway.SOAPTransaction.<init>(SOAPTransaction.java:192) at com.eibus.web.soap.Gateway.service(Gateway.java:75) at com.eibus.web.isapi.WebApplication.handleExtensionControlBlock(WebApplication.java:93) at com.eibus.web.isapi.ExtensionControlBlock.execute(ExtensionControlBlock.java:100) at com.eibus.web.isapi.ExtensionControlBlock.run(ExtensionControlBlock.java:71) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: com.eibus.exception.ExceptionGroup: Failed to send message to [cn=LDAP,cn=soap nodes,o=system,cn=cordys,cn=cordys_43,o=ADNATEITSOLUTIONS.COM]. [com.eibus.exception.BusException: No SOAPProcessor available for: cn=LDAP,cn=soap nodes,o=system,cn=cordys,cn=cordys_43,o=ADNATEITSOLUTIONS.COM] at com.eibus.transport.Middleware.send(Middleware.java:1005) at com.eibus.connector.nom.Connector.send(Connector.java:1152) at com.eibus.connector.nom.Connector.sendAndWait(Connector.java:923) at com.eibus.directory.soap.LDAPSearchCache.search(LDAPSearchCache.java:439) ... 28 more </cordys:FaultRelatedException>
</detail>
</SOAP:Fault>
</SOAP:Body>
</SOAP:Envelope>
</Response>
</ErrorDetails>
It simply states that the LDAP Service Container (SOAP Processor) is not running. Restart Cordys Monitor Service.

WCF Client for Axis2/Rampart Webservice using WS security without client certificate

I´m just facing some problems setting up a WCF(.NET 4.0) webservice to call an Axis2 Rampart webservice.
I´m new to WCF and i didn´t find a tutorial wich completly fits this special scenario.
Here are the facts:
The webservice i have to call is an Axis2 Ramart service.
The Client i need to build uses WCF/.NET 4.0.
The Webservice uses SOAP 1.1 and WS-Security (Messagesecurity).
WS-Securtity should work like this:
The server provides a certificate with the public key.
The client generates a secret symmetric key.
The client encrypts this secret key with the servers public key.
This encrypted key is written into the Soap-header.
The client encrypts the body of the Soap request with the secret key.
(In fact the dodumentation I got from the webservice provider says that the body is encrypted with the servers public key, but in the sample request they provide, the encryption method is stated as aes128-cbc wich is a symmetric key AFAIK)
So this is what i have to do.
What i have done so far was to try some custom bindings from several tutorials.
But all samples I found uses server AND CLIENT-certificates and I didn´t managed to adjust these bindings in a way that works for me.
So here is a sample-request that shows how the request should look like:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
<xenc:EncryptedKey Id="EncKeyId-Cl6B57CC684EEpm8E6E61WBp3421878712">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<wsse:SecurityTokenReference>
<wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1">D99lKi5jizWOxThG6yZXw6llwq4FdM=</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>Ab5i63RFNPNXcoEn6PqflaoPjsUI3E5EZh668621xkMcEDz9Jcm204A5Ecn8WQamxKX7UYEG8gPwn66X+pOj0DiWD4ShKVJIOD5gCliobcGgjVB1Uihj8Xk5MGesi8atuy9RFA=</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedKey>
<wsc:DerivedKeyToken xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="derivedKeyId-1">
<wsse:SecurityTokenReference>
<wsse:Reference URI="#EncKeyId-Cl6B57CC684EEpm8E6E61WBp3421878712"
ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey" />
</wsse:SecurityTokenReference>
<wsc:Offset>0</wsc:Offset>
<wsc:Length>16</wsc:Length>
<wsc:Nonce>wQ9oyLHKjKRx6Dlm04RaL5Q==</wsc:Nonce>
</wsc:DerivedKeyToken>
<xenc:ReferenceList>
<xenc:DataReference URI="#EncDataId-2" />
</xenc:ReferenceList>
</wsse:Security>
</soapenv:Header>
<soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-15079889">
<xenc:EncryptedData Id="EncDataId-2" Type="http://www.w3.org/2001/04/xmlenc#Content">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc" />
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Reference URI="#derivedKeyId-1" />
</wsse:SecurityTokenReference>
</ds:KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>
+Tx9+XL7QqFVZKCr5wEhyOBENlCfHm0y1y5yWwnIk2kHNoO3IFFJj2rSQdt7HiqfcU6XxAVn3eVJKmmuN+rPYISoJstl8EnStaEIqSTuUyTUrgchx5Zxor47TOknXXjo3dYhTKHqvsx8SX70GG3M+bJS/Q1CWDlWzidKWxORo8D02iVcQdu00dnw7SHWYwyzzhduQbsozyzcAER5cYnQuuUPOcBusivq/L0xDOVTFaGr9/vvPGo+yk2bN0nBLeikk0uSJr7Z/IqGL+Dqg5BA0f+8X8sxFQpRQmtSoXtvhs2bGy8v1MPkCYKPmajSR/XwMaQB2zxR6vKsGA7ODH9+ocqO+rbPOYWpRz+czogOUo5s+OYIwX9u+99NmC5zuSjvK5bwJzWWrJ0h31OM0KeTkc7rxTIm8QMR5ytBNnCtU9QXQeAMbBdwGok330rq5ZH9bN4TdBg9Qhzs8CGGpjMYZaQ9ApTt6vkGK0i9gtdXdvY1fVZpsPcU67MYvkXJARQMpwj9Z3ZDVscdiPIxvfHyBkT8Ta21mDlYRidxanr87CrLB6HyiEyhD1XKwpTZ7OpNja6UOzfGNOJx07SbgGF+ozDBaC7zs691L4iawDioXagUZSkQ9UgwaqycSh3YYa5+RYuPka1Z0z2cmdAaFnEtoZAaSftGj8k=
</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
</soapenv:Body>
</soapenv:Envelope>
Perhaps someone could tell me how I can accomplish this, or where I can find some tutorials.
Thank you in advance.
This is the Resposne I get after I´ve implementet the Custom Binding and the Messsage-Encoder:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
<wsc:DerivedKeyToken xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="derivedKeyId-159">
<wsse:SecurityTokenReference>
<wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKeySHA1">Aef7igYIlyWYa9XrbSYSt9Lh5Q4=</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
<wsc:Offset>0</wsc:Offset>
<wsc:Length>16</wsc:Length>
<wsc:Nonce>Ub30ogcNT6p7ZkH+qXFclw==</wsc:Nonce>
</wsc:DerivedKeyToken>
<wsc:DerivedKeyToken xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="derivedKeyId-159">
<wsse:SecurityTokenReference>
<wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKeySHA1">">Aef7igYIlyWYa9XrbSYSt9Lh5Q4=</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
<wsc:Offset>0</wsc:Offset>
<wsc:Length>16</wsc:Length>
<wsc:Nonce>Ub30ogcNT6p7ZkH+qXFclw==</wsc:Nonce>
</wsc:DerivedKeyToken>
<xenc:ReferenceList xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
<xenc:DataReference URI="#EncDataId-160"/>
</xenc:ReferenceList>
</wsse:Security>
</soapenv:Header>
<soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-1046510178">
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="EncDataId-160" Type="http://www.w3.org/2001/04/xmlenc#Content">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Reference URI="#derivedKeyId-159"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>zQUBHBX2nMTfL5gxXseNqqE5goAFSPQEd2D1RAsUZi+L64gqYfdQQIg//hWhw0Ed9gGFxLX8/ocq
svVX7oVTN4YkCF9LdLmY1y7/SmbDMyjKjzhxvQ5Bz2mu1EzWBtWRjAYGnMtLTJCCWEK0ZeqKGXDi
rqcHMwJYK4vGKeizAl/BMN2dLqp4gANSHB7kryGYiK4C2NncYwpbbws/It6Lm2RPuUenFW+2VCaC
OW8YdCMMfveEvO+18+BaApxS2ShckTbip9nbpDzVvGw4gFw/70xAupMkkUEGJPdBnb6ce9qC/jQm
MeBL4FSenEJbqR1qSU5xh6rD7m6Vqug5mEP7c2Tk/mPSFVlZ88TXV2S31NB+3PDAXxyZss9aftBl
L+q+m8oP/hqse9Oju8MaztP/gBQDSKuTBLWgMPvwluEZmnPnpItZX9CFOVGDaaWlnoN1Lgc6iKk/
8xDC95t87++NesK6Zqa+J15qGm4MozFBe5pS75wARrGA34USnHytNNJGyidx15wQgNrT9gxTlypQ
BU3830rWiWAsrFwzSQBC20TcNb0ofscNJqVhwmRnMHz75Gbn70jyGTM0W27PFYfq/xfJ3MCe/pov
Dqn647j2Ixvj/Rik02HJdUUm/cdmRxawWQVUvmxPbPNNOjCoccwOWxf623zXpD3DdV8U/5+jDite
eQnrpaU4griXc7jq85OIoghf++cShAK+tx5t8BjLaD1rBF3ni5Eqt2xbMoZ6cfzr314PxmffyjHM
rCzSMU4cw0BndzJrV2r0aKTEPxVRPIQur8ztEtIYCRWloceS4N2YKkdRm/W7TWBsIa+HOCpq9Rpr
bu0KLP54tBBTO5hzjIsjYn7JzfohYk5aDN/8ZsQqgsO0LhWu/9qj8j2fY+yC4W9i7m+/bLvuYSbO
Tm7B0vV5s79uG4Xi/ONM7O1NR/C1HSEddQnr0/zdDxJcJsxwAmyryILmLynaZyxeFYz5ueqQuNCZ
MTRvKdEfw2+Tt7l3lUSZ/WqPcAz2UFA7kdASk2esmQjVZjvvdLQfan7xHffU1Ga5nmafuXrCZR81
k+1OYs64oy14qFor0e3DXlyeUOPC67iEP92lBQl7hz4v9I0afSmEhmc3iR/XoYTgliP2QhkeEw11
gSGa9u6oLfQfGZVsDV6meL51kkM+FRKq8Y2QjJjSyVFUzQXmg0lAySjlTjVeYZbRCSleCSqk+tIJ
XIcsdkY9PSVxdWOiqXQcQlrae1Wj34Xf+h6NpNuIt/TSKxd896b0ACzz8ouHUvI/Wyk5Rz/Rmvzi
g/cGK9YnX8VGV2hpUzsVZLByUoWvMH+hv9ep1syQiA5EiIu+paTS92CW1i2x39pnKeMrYhI6Ug==</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
</soapenv:Body>
</soapenv:Envelope>
And This is the ReadMessage-Function of My MessageEncoder (I know it´s not the best way to parse Xml). It removes one of the two derived keys:
public override Message ReadMessage(ArraySegment<byte> buffer, BufferManager bufferManager, string contentType)
{
var msg = innerEncoder.ReadMessage(buffer, bufferManager, contentType);
var xml = msg.ToString();
var msgbuffer = msg.CreateBufferedCopy( int.MaxValue );
msg = msgbuffer.CreateMessage();
MemoryStream stream = new MemoryStream();
XmlDictionaryWriter xmlWriter = XmlDictionaryWriter.CreateBinaryWriter(stream);
msg.WriteMessage(xmlWriter);
xmlWriter.Flush();
stream.Position = 0;
XmlDictionaryReader xmlReader = XmlDictionaryReader.CreateBinaryReader(stream, XmlDictionaryReaderQuotas.Max);
XmlDocument doc = new XmlDocument();
doc.Load(xmlReader);
XmlNode security = null;
XmlNode derivdeKey = null;
foreach (XmlNode xnode in doc.DocumentElement.FirstChild.ChildNodes)
{
if (xnode.LocalName == "Security")
foreach (XmlNode node in xnode.ChildNodes)
{
security = node;
if(node.LocalName == "DerivedKeyToken")
{
}
if(derivdeKey != null)
{
XmlNode pnode = node.ParentNode;
pnode.RemoveChild( node );
}
else
{
derivdeKey = node;
}
}
}
Stream memStream = new MemoryStream();
xmlWriter = XmlDictionaryWriter.CreateBinaryWriter( memStream );
doc.WriteTo(xmlWriter);
xmlWriter.Flush();
memStream.Position = 0;
xmlReader = XmlDictionaryReader.CreateBinaryReader(memStream, XmlDictionaryReaderQuotas.Max);
Message newMessage = Message.CreateMessage(xmlReader, 10240, msg.Version);
xml = newMessage.ToString();
return newMessage;
}
I`m wondering about how the Message is shown as string (newMessage.ToString()) because the body is shon was ...stream....
The Problem is that I get the followingError-message:
System.ServiceModel.Security.MessageSecurityException : The 'Body', 'http://schemas.xmlsoap.org/soap/envelope/' required message part was not signed.
So I stripped of the Security node as descriped here http://webservices20.blogspot.de/2012/04/when-enableunsecuredrespose-requires.html.
This is the stripped resonse:
<?xml version="1.0" encoding="utf-16"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body wsu:Id="Id-1532543044" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><xenc:EncryptedData Id="EncDataId-586" Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"></xenc:EncryptionMethod><ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:Reference URI="#derivedKeyId-585"></wsse:Reference></wsse:SecurityTokenReference>
</ds:KeyInfo><xenc:CipherData><xenc:CipherValue>APZ9aATpcMu5qU6PdoKeTLjAblJP/uLZAzX8imgSSfvaZGGeI8prg9JNTEOjZ1SAeuWxod/ZV4pb
3OeY3b1IWxxhG5WWGxu51WAAehGBmiyFYOzJwbpR5cOHUc7aRBm7hkeqr/1RlcYDlAk4Y+G1URgv
0K2nzqfDR3m7ydZSVoa3aSWWzmhjMTnJnPyQ060fDXiU7/k0tI12danfv+tUcBAlvfssTTEB33bH
RXTjobJDuW3lEbbQBN+KD9SUu02GvFF4Vs31pSf1YxHIzMuf3Q2njz58oY0kmDRvR6+n9IIUQVgK
5+iJOx9E5pY7xzmEf5LpbiTt2RSuxmt2+nkin+wxF94hkgW/N6TwmbbjybN2TY3IyZ2PgdzobCj9
sG9UAwAE1peDvIpiXhgXyojU7eRnAfJKE4HrxEjs9GKdgA4SG3rsM7t/JAeiThqe4GZCvrKwnTHS
OZSz8wplTEV7VfALj5TvwK8DqOP4Qsk1F6pml/IQg0YSUJGQmuxZzTiM3ABRzf21/BUj9j3mlo7R
/QFhNnEAhHTLoJIW1fhKYrhT7vk6rMLlZtP7iyE63MEp4cghvSk9OZDauUBoUAkKwv9N2TSOBe3W
N0fVIpLg+gNmu8s1Myzl9MEDpqQFvJbG2+hTjREo9cyvfJdKLjZVpWVoaaghiZrOFwUWJsIGCyuy
aW+eF1wFP6WgXixmvX/mdkEqCyU29+DAlIb5yIABgIxNk4MSJP/9+cSZ7L6EOVJc9khsMgw1aGe9
k3QbIeM7WLXcHNnWFE+PuqORg7OvvG+jqFGyfGlGaE85lbD2+0ONTmxU3MwNhg9ngZLheiIzxxty
3R2KXDMkDEQpWJ7cIi2QSvwu0XZ/Ku5hwW8fXbUgHTClpAQbwu3HqeeHv2BkhrUbPbx3pRpu6B4L
tyGO4vfp/vlnPyT0xS5O99KX6iKpDDS3zqC9j0cheJIqIvixNvrLd/KrpQJ8nc7+B/29h444y/3I
jooRtDmtNuG2T3b4QB2oec7FS+ufXUJIEgPWtE6iPMZxMqiL1z64eL0sg2xO4QXWwoGzMCZHP89y
ibhjhsKDTffz/s4cgRgzRWAQSNlLpuvzDeHjbNUnXIz3C1NnQOBV0LF5KpCuyYeIfQDbJQpyTre1
q5KMTGHq4ksG2zSpgNNouS279WmlGOmuawLW28VxRBlW92K//l16yJglEcKbqlRuxzM0gcw1BG/O
9sp25te+Ad68Vo2dyELZYstIRhSnV2j2J6UyZd1WC1rBWHiu3gDvKgeCNtgUbeHKfm0RVo9ZBVbi
vHQWAL57hOBERoXK5MkhwqlsYZzOHzkoVyxok+UspcmVy1MQccOcB6y5xbuqt6zR+iFuKyZVGQ==</xenc:CipherValue></xenc:CipherData></xenc:EncryptedData></soapenv:Body></soapenv:Envelope>
Now the Service finishes without errors, but the result-object is null.
-> example:
result = testserviceproxy.testservicefunction();
result is null;
This binding is the closest you could get with ootb wcf:
<customBinding>
<binding name="NewBinding0">
<textMessageEncoding messageVersion="Soap11" />
<security defaultAlgorithmSuite="Basic128Rsa15" authenticationMode="AnonymousForCertificate"
includeTimestamp="false" messageProtectionOrder="EncryptBeforeSign">
<secureConversationBootstrap />
</security>
<httpTransport />
</binding>
</customBinding>
It produces a very similar XML with one different: It also adds a digital signature. There is no way to directly tell WCF not to add a signature. Most chances are this will not be a problem for you to send the message as is (with signature). If this is a problem you could implement a WCF custom message encoder to manually remove the signature element (and also the one out of two derived keys which is used specifically for signature).

Paypal sandbox endpoint webservice - Error "You do not have permissions to make this API call"

I used this paypal endpoint webservice for my PHP5 SoapClient :
Sandbox API Signature SOAP https://api-3t.sandbox.paypal.com/2.0/
And when i send my soap request with my credentials, i get an error with :
Ack => failure
ErrorCode => 10002
Short message => Authentication/Authorization failed
Long message => You do not have permissions to make this API call
This is current Soap message send to soap paypal API :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:ebay:apis:eBLBaseComponents"
xmlns:ns2="ebl:SetExpressCheckoutRequestDetails"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns3="urn:ebay:api:PayPalAPI"
xmlns:ns4="ebl:UserIdPasswordType">
<SOAP-ENV:Header>
<ns3:RequesterCredentials xsi:type="ns4:UserIdPasswordType">
<Username>xxxxx</Username>
<Password>xxxxx</Password>
<Signature>xxxxx</Signature>
</ns3:RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns3:SetExpressCheckoutReq>
<ns3:SetExpressCheckoutRequest>
<ns1:Version>84.0</ns1:Version>
<ns1:SetExpressCheckoutRequestDetails
xsi:type="ns2:SetExpressCheckoutRequestDetailsType">
<ReturnUrl>url_to_/success.paypal.php</ReturnUrl>
<CancelUrl>url_to_/cancel.paypal.php</CancelUrl>
<LocaleCode>US</LocaleCode>
</ns1:SetExpressCheckoutRequestDetails>
</ns3:SetExpressCheckoutRequest>
</ns3:SetExpressCheckoutReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I instantiated this PHP5 SoapClient :
//Endpoint
$location = 'https://api-3t.sandbox.paypal.com/2.0/';
$uri = 'urn:ebay:api:PayPalAPI';
//SoapClient options
$options = array('trace' => 1, 'exceptions' => 1, 'location'=>$location, 'uri'=>$uri);
//My Soap Client
$client =new SoapClient('https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl',$options);
But when I called SetExpressCheckout paypal soap service, i receive the following soap message :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cc="urn:ebay:apis:CoreComponentTypes"
xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"
xmlns:ed="urn:ebay:apis:EnhancedDataTypes"
xmlns:ebl="urn:ebay:apis:eBLBaseComponents"
xmlns:ns="urn:ebay:api:PayPalAPI">
<SOAP-ENV:Header>
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"
xsi:type="wsse:SecurityType"></Security>
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI"
xsi:type="ebl:CustomSecurityHeaderType">
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents"
xsi:type="ebl:UserIdPasswordType">
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body id="_0">
<SetExpressCheckoutResponse xmlns="urn:ebay:api:PayPalAPI">
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">
2012-01-13T12:09:01Z
</Timestamp>
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">
c8d551f118a1
</CorrelationID>
<Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
<ShortMessage xsi:type="xs:string">
Authentication/Authorization Failed
</ShortMessage>
<LongMessage xsi:type="xs:string">
You do not have permissions to make this API call
</LongMessage>
<ErrorCode xsi:type="xs:token">10002</ErrorCode>
<SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">
Error
</SeverityCode>
</Errors>
<Version xmlns="urn:ebay:apis:eBLBaseComponents">84.0</Version>
<Build xmlns="urn:ebay:apis:eBLBaseComponents">2271164</Build>
</SetExpressCheckoutResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Nevertheless, I used the API credentials of my business account test...
I don't understand why my code doesnt work.
The error is : 'You do not have permissions to make this API call', but how it's possible? Because i use the correct endpoint service (sandbox) ?

PayPal API using SOAP

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>