Validating OAuth2 token in WSO2 - oauth-2.0

I want to use WSO2 for sso. When i'm going to validate token code in SoapUI i'm facing with Invalid access token error.
I registered and i'm redirect to this URL:
http://MyRedirectPage/?code=63873a38-40c6-3240-850c-a50bf7ad8883&session_state=7877d1d733d534206c4247b31d63d95bd3e3dda9d77cd819b4d81e7eeabceb45.Xq6OQiFUARHShBxUZtFHTQ
I'm using code parameter for validation: 63873a38-40c6-3240-850c-a50bf7ad8883
Here is my code in SoapUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd" xmlns:xsd1="http://dto.oauth2.identity.carbon.wso2.org/xsd">
<soapenv:Header/>
<soapenv:Body>
<xsd:validate>
<!--Optional:-->
<xsd:validationReqDTO>
<!--Optional:-->
<xsd1:accessToken>
<!--Optional:-->
<xsd1:identifier>63873a38-40c6-3240-850c-a50bf7ad8883</xsd1:identifier>
<!--Optional:-->
<xsd1:tokenType>Bearer</xsd1:tokenType>
</xsd1:accessToken>
<!--Zero or more repetitions:-->
<xsd1:context>
<!--Optional:-->
<xsd1:key>?</xsd1:key>
<!--Optional:-->
<xsd1:value>?</xsd1:value>
</xsd1:context>
<!--Zero or more repetitions:-->
<xsd1:requiredClaimURIs>?</xsd1:requiredClaimURIs>
</xsd:validationReqDTO>
</xsd:validate>
</soapenv:Body>
</soapenv:Envelope>
And here is the result:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:validateResponse xmlns:ns="http://org.apache.axis2/xsd">
<ns:return xsi:type="ax2395:OAuth2TokenValidationResponseDTO" xmlns:ax2395="http://dto.oauth2.identity.carbon.wso2.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax2395:authorizationContextToken xsi:nil="true"/>
<ax2395:authorizedUser xsi:nil="true"/>
<ax2395:errorMsg>Invalid access token</ax2395:errorMsg>
<ax2395:expiryTime>0</ax2395:expiryTime>
<ax2395:scope xsi:nil="true"/>
<ax2395:valid>false</ax2395:valid>
</ns:return>
</ns:validateResponse>
</soapenv:Body>
</soapenv:Envelope>
Would you please tell me what is wrong?

It seems you're trying to validate the authorization code. (Why are you doing that?) This service is only for validating access tokens.

Related

Need to add variables to SOAP request without SAVON

I need to be able to add variables to the following XML from the server-side. Is there a way to do this? I cannot use SAVON to handle the request.
data = <<-EOF
<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/>
<soapenv:Body>
<CheckoutShoppingCart xmlns="http://clients.mindbodyonline.com/api/0_5_1">
<Request>
<XMLDetail>Full</XMLDetail>
<ClientID><!-- client_id goes here --></ClientID>
</Request>
</CheckoutShoppingCart>
</soapenv:Body>
</soapenv:Envelope>
EOF
result= http.post(uri.path, data)
data = <<-EOF
<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/>
<soapenv:Body>
<CheckoutShoppingCart xmlns="http://clients.mindbodyonline.com/api/0_5_1">
<Request>
<XMLDetail>Full</XMLDetail>
<ClientID>#{client_id}</ClientID>
</Request>
</CheckoutShoppingCart>
</soapenv:Body>
</soapenv:Envelope>
EOF

IBM BUS Change Soap Namespace of Responce

My Soap Responce like
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Response xmlns="http://tempuri.org/">
<Result>
<Result>LOGON FAILED</Result>
</Result>
</Response>
</soapenv:Body>
</soapenv:Envelope>
But, I need change the prefix of namespace and responce and must like this one.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Response xmlns="http://tempuri.org/">
<Result>
<Result>LOGON FAILED</Result>
</Result>
</Response>
</soapenv:Body>
</soap:Envelope>
If you are using ESQL to construct your message you can do this as described here:
https://www.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ac67194_.htm
DECLARE soapNs NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
DECLARE tempNs NAMESPACE 'http://tempuri.org/';
SET OutputRoot.XMLNSC.soapNs:Envelope.(XMLNSC.NamespaceDecl)xmlns:soap = soapNs;
SET OutputRoot.XMLNSC.soapNs:Envelope.soapNs:Body.tempNs:Response.(XMLNSC.NamespaceDecl)xmlns = tempNs;
SET OutputRoot.XMLNSC.soapNs:Envelope.soapNs:Body.tempNs:Response.tempNs:Result.tempNs:Result = 'LOGON FAILED';
But still, the value of the namespace tags shouldn't make a difference.

How to convert string to xml in iOS? (objective C, xcode 7.2)

I want to convert a NSString variable containing xml codes into xml format. My xml request is:
<?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>
<Authentication xmlns="(namespace link)">
<Credentials>
<Username>username</Username>
<Password>password</Password>
</Credentials>
</Authentication>
</soapenv:Body>
</soapenv:Envelope>
then i saved this request to a NSString variable. And i got response for this as the server didn't recognize as xml. So how to convert the string i saved into xml?
Simple code for SOAP request and parsing.
Goto the link: https://yuvarajmanickam.wordpress.com/2012/10/17/soap-message-request-and-xmlparsing-in-ios-app/
or
github.com/nicklockwood/XMLDictionary
or
stackoverflow.com/questions/803676/encode-nsstring-for-xml-html

How to call an array in SOAP with SAVON 2 in rails 4

request via SOAP UI
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header/>
<soapenv:Body>
<tem:GetLastDayRounds>
<!--Optional:-->
<tem:glIds>
<!--Zero or more repetitions:-->
<arr:int>7910</arr:int>
<arr:int>791524</arr:int>
<arr:int>5613</arr:int>
</tem:glIds>
</tem:GetLastDayRounds>
</soapenv:Body>
</soapenv:Envelope>
respond via SOAP UI
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetLastDayRoundsResponse xmlns="http://tempuri.org/">
<GetLastDayRoundsResult xmlns:a="http://schemas.datacontract.org/GL.WS" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Message i:nil="true"/>
<a:Rounds xmlns:b="http://schemas.datacontract.org/GL.WS.Entities">
<b:Round>
<b:AdjustedScore>91</b:AdjustedScore>
</b:Round>
<b:Round>
<b:AdjustedScore>92</b:AdjustedScore>
</b:Round>
<b:Round>
<b:AdjustedScore>191</b:AdjustedScore>
</b:Round>
</a:Rounds>
<a:Status>Success</a:Status>
</GetLastDayRoundsResult>
</GetLastDayRoundsResponse>
</s:Body>
</s:Envelope>
This is how I made the connection:
url = "http://api.wsdl.address"
#client = Savon.client(
wsdl: url,
namespace: "http://tempuri.org/",
env_namespace: :soapenv,
log: true, # set true to switch on logging
log_level: :debug,
pretty_print_xml: true,
open_timeout: 3000000,
read_timeout: 3000000
)
Now this is what I think my SAVON 2 call should be:
response = #client.call(:get_last_day_rounds, message: {"tns:glIds" => [7910,791524]})
But I get internal error form the supplier. If I test this via SOAP UI I get the result and all fine, however I cant figure it out how to do it via SAVON 2.
Thanks.
SAVON 2 Log:
At the request:
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<tns:GetLastDayRounds>
<tns:glIds>7910</tns:glIds>
<tns:glIds>791524</tns:glIds>
</tns:GetLastDayRounds>
</soapenv:Body>
</soapenv:Envelope>
respond:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
<faultstring xml:lang="en-AU">The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>
I tried this too:
response = #client.call(:get_last_day_rounds, message: { "tns:glIds" => { "int" => [79124,123] } } )
SAVON Log:
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<tns:GetLastDayRounds>
<tns:glIds>
<int>791524</int>
<int>123</int>
</tns:glIds>
</tns:GetLastDayRounds>
</soapenv:Body>
</soapenv:Envelope>
I got the the following error
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
<faultstring xml:lang="en-AU">The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>
Ok, I found it. (In case someone use it)
The namespace needs to be changed.
So the call will be:
def make_connection
url = "http://api.wsdl.link"
#client = Savon.client(
wsdl: url,
namespaces: {
"xmlns:tem" => "http://tempuri.org/",
"xmlns:arr" => "http://schemas.microsoft.com/2003/10/Serialization/Arrays"
},
env_namespace: :soapenv,
log: true, # set true to switch on logging
log_level: :debug,
pretty_print_xml: true,
open_timeout: 3000000,
read_timeout: 3000000
)
end
Now when I call:
response = #client.call(:get_last_day_rounds, message: {"tns:glIds" => { "arr:int" => [5613,79810] } })
I get the result
Cheers

Savon is returning no result in Rails 4?

I have asked this question in here
Savon 2 returns nothing
And got the answer. Thanks to +Steffen Roller
Now most of my Soap API are sorted.
With this one, I have tried everything still nothing I get. I thought it should work as the USZip worked. Apparently not :(
Soap API:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:GetHistoryByID>
<!--Optional:-->
<tem:personId>789834133</tem:personId>
</tem:GetHistoryByID>
</soapenv:Body>
</soapenv:Envelope>
SoapUI response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetHistoryByIDResponse xmlns="http://tempuri.org/">
<GetHistoryByIDResult xmlns:a="http://schemas.datacontract.org/2004/07/Domain.MySite.WS" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:ErrorMessage i:nil="true"/>
<a:Rounds xmlns:b="http://schemas.datacontract.org/2004/07/Domain.MySite.WS">
<b:Round>
<b:AdjustedGross>104</b:AdjustedGross>
<b:MainField>14</b:MainField>
</b:Round>
<b:Round>
<b:AdjustedGross>101</b:AdjustedGross>
<b:MainField>14</b:MainField>
</b:Round>
</a:Rounds>
<a:Status>Success</a:Status>
</GetHistoryByIDResult>
</GGetHistoryByIDResponse>
</s:Body>
</s:Envelope>
Here is my Savon
require 'savon'
require 'pp'
a_url = 'wsdl link in here'
client = Savon.client(
wsdl: a_url,
log: true, # set true to switch on logging
log_level: :debug,
pretty_print_xml: true
)
person_id = "12345"
response = client.call(:get_history_by_id, message: { "personId" => person_id }
)
And response is this:
{:get_history_by_id_response=>{:get_history_by_id_result=>{:error_message=>nil, :rounds=>{:"#xmlns:b"=>"http://schemas.datacontract.org/2004/07/Domain.MySite.Entities"}, :status=>"Success", :"#xmlns:a"=>"http://schemas.datacontract.org/2004/07/Domain.MySite.WS", :"#xmlns:i"=>"http://www.w3.org/2001/XMLSchema-instance"}, :#xmlns=>"http://tempuri.org/"}}
Thanks again guys.
Update:
Savon log:
D, [2014-06-13T10:14:56.457008 #3157] DEBUG -- : HTTPI GET request to api.mysite.com.au (httpclient)
I, [2014-06-13T10:14:56.569055 #3157] INFO -- : SOAP request: http://api.mysite.com.au/MyDomain/DomainCCService.svc
I, [2014-06-13T10:14:56.569113 #3157] INFO -- : SOAPAction: "http://tempuri.org/IDomainCCService/GetHistoryById", Content-Type: text/xml;charset=UTF-8, Content-Length: 382
D, [2014-06-13T10:14:56.569214 #3157] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://tempuri.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<tns:GetHistoryById>
<personId>789834133</personId>
</tns:GetHistoryById>
</soapenv:Body>
</soapenv:Envelope>
D, [2014-06-13T10:14:56.569418 #3157] DEBUG -- : HTTPI POST request to api.mysite.com.au (httpclient)
I, [2014-06-13T10:14:56.902413 #3157] INFO -- : SOAP response (status 200)
D, [2014-06-13T10:14:56.902625 #3157] DEBUG -- : <?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetHistoryByIdResponse xmlns="http://tempuri.org/">
<GetHistoryByIdResult xmlns:a="http://schemas.datacontract.org/2004/07/Domain.MySite.WS" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:ErrorMessage i:nil="true"/>
<a:Rounds xmlns:b="http://schemas.datacontract.org/2004/07/Domain.MySite.Entities"/>
<a:Status>Success</a:Status>
</GetHistoryByIdResult>
</GetHistoryByIdResponse>
</s:Body>
</s:Envelope>
Thanks
The simplest solution is to include the namespace into your tag. At least that's what I use to do.
Replace "personID" with "tns:personID". That should do it.

Resources