wait, note that the line is in the section 3 and it belongs to the soapUI
http logs, not to esb's one. :( sorry, take a look at the esb's and you'll
see that the request is not ok...

can you send me your sequence code and the corresponding http logs in order
to compare with mine?

On Sat, Jan 9, 2016 at 1:03 AM, John Q <[email protected]> wrote:

> Oh god I didn't see it before, I was only trying to see it using the log
> mediator as I used to do. thanks a lot, by the way, is there any available
> book of wso2? even paid?
>
> thanks again.
> john
>
> On Sat, Jan 9, 2016 at 12:35 AM, Harsha Kumara <[email protected]> wrote:
>
>> Following line indicate that you are getting the token. You may use xpath
>> or appropriate json function to extract it.
>>
>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<<
>> "{"scope":"default","token_type":"bearer","expires_in":2789,"refresh_token":"15b792d5c48dbe1c8a9a88ce6d4542cf","access_token":"bdf05b9c1eed3ce21317d8a5581b17"}"
>>
>>
>> On Sat, Jan 9, 2016 at 10:32 AM, John Q <[email protected]> wrote:
>>
>>> Harshak,
>>> Your  help has been very useful, but I haven't solved it yet.
>>>
>>> see above
>>>
>>> 1. the code inside the sequence into de esb
>>> 2. the http logs from esb (doesn't work).
>>> 3. the http logs from soapui (it works).
>>>
>>> 1.
>>>
>>> <payloadFactory media-type="json">
>>>
>>>     <format>
>>>
>>> {"grant_type":"password","username":"admin","password":"admin"}
>>>
>>> </format>
>>>
>>>     <args/>
>>>
>>>   </payloadFactory>
>>>
>>>   <property
>>>
>>>     expression="fn:concat('Basic
>>> ','SW9Mb0ZCQ3lkaE9yVXhjQUtiTGpEVmloMU9RYTpWakhITjR2RXl5REFXVTBlbmdqZWxYeFp5M2th')"
>>>
>>>     name="Authorization" scope="transport" type="STRING" xmlns:ns="
>>> http://org.apache.synapse/xsd"/>
>>>
>>>   <property name="messageType" scope="axis2" type="STRING" value=
>>> "application/x-www-form-urlencoded"/>
>>>
>>>   <call>
>>>
>>>     <endpoint>
>>>
>>>       <http method="post" trace="disable" uri-template="
>>> https://localhost:8243/token"/>
>>>
>>>     </endpoint>
>>>
>>>   </call>
>>>
>>> 2.
>>>
>>>
>>> [2016-01-09 00:00:01,091] DEBUG - wire << "POST /token HTTP/1.1[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,091] DEBUG - wire << "FILE_NAME: New
>>> Account.xml.F826AAF56484284EE41451927537179.xml[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,091] DEBUG - wire << "Authorization: Basic
>>> SW9Mb0ZCQ3lkaE9yVXhjQUtiTGpEVmloMU9RYTpWakhITjR2RXl5REFXVTBlbmdqZWxYeFp5M2th[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "Content-Type:
>>> application/x-www-form-urlencoded; charset=UTF-8[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "FILE_PATH:
>>> /Users/javier/iralogix/in/New
>>> Account.xml.F826AAF56484284EE41451927537179.xml[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "FILE_URI:
>>> file:///Users/javier/iralogix/in/New
>>> Account.xml.F826AAF56484284EE41451927537179.xml[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "SOAPAction:
>>> urn:mediate[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "Transfer-Encoding:
>>> chunked[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "Host: localhost:8243[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "Connection:
>>> Keep-Alive[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "User-Agent:
>>> Synapse-PT-HttpComponents-NIO[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,092] DEBUG - wire << "6e[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,093] DEBUG - wire <<
>>> "<jsonObject><grant_type>password</grant_type><username>admin</username><password>admin</password></jsonObject>[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,093] DEBUG - wire << "0[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,093] DEBUG - wire << "[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,102] DEBUG - wire >> "HTTP/1.1 400 Bad
>>> Request[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,102] DEBUG - wire >> "Content-Type:
>>> application/json[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,102] DEBUG - wire >> "Date: Sat, 09 Jan 2016
>>> 05:00:01 GMT[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,103] DEBUG - wire >> "Server:
>>> WSO2-PassThrough-HTTP[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,103] DEBUG - wire >> "Transfer-Encoding:
>>> chunked[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,103] DEBUG - wire >> "Connection: Close[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,103] DEBUG - wire >> "[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,104] DEBUG - wire >> "54[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,104] DEBUG - wire >>
>>> "{"error":"invalid_request","error_description":"Missing grant_type
>>> parameter value"}[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,104] DEBUG - wire >> "0[\r][\n]"
>>>
>>> [2016-01-09 00:00:01,104] DEBUG - wire >> "[\r][\n]"
>>>
>>>
>>> 3.
>>>
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "POST
>>> /token?grant_type=password&username=admin&password=admin HTTP/1.1[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "Accept-Encoding:
>>> gzip,deflate[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "MIME-Version: 1.0[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "Authorization: Basic
>>> SW9Mb0ZCQ3lkaE9yVXhjQUtiTGpEVmloMU9RYTpWakhITjR2RXl5REFXVTBlbmdqZWxYeFp5M2th[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "Content-Type:
>>> application/x-www-form-urlencoded[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "Content-Length: 45[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "Host: localhost:8243[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "Connection: Keep-Alive[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "User-Agent:
>>> Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>>
>>> "------=_Part_2_1407486111.1452314212801--"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:>> "[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "HTTP/1.1 200 OK[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "Content-Type:
>>> application/json[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "Pragma: no-cache[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "Cache-Control: no-store[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "Date: Sat, 09 Jan 2016 04:36:52
>>> GMT[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "Server:
>>> WSO2-PassThrough-HTTP[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "Transfer-Encoding:
>>> chunked[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "Connection: Keep-Alive[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "9e[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<<
>>> "{"scope":"default","token_type":"bearer","expires_in":2789,"refresh_token":"15b792d5c48dbe1c8a9a88ce6d4542cf","access_token":"bdf05b9c1eed3ce21317d8a5581b17"}"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "0[\r][\n]"
>>>
>>> Fri Jan 08 23:36:52 EST 2016:DEBUG:<< "[\r][\n]"
>>>
>>>
>>>
>>> On Fri, Jan 8, 2016 at 10:58 PM, Harsha Kumara <[email protected]> wrote:
>>>
>>>> Hi John,
>>>>
>>>> I have tested the given API, it's working perfectly. You can enable
>>>> wire logs in ESB as in [1] and check your incoming and outgoing requests.
>>>>
>>>> [1] -
>>>> http://mytecheye.blogspot.com/2013/09/wso2-esb-all-about-wire-logs.html
>>>>
>>>>
>>>> Thanks,
>>>> Harsha
>>>>
>>>> On Sat, Jan 9, 2016 at 1:49 AM, John Q <[email protected]> wrote:
>>>>
>>>>> I was doing that, but I get this response
>>>>>
>>>>> <soapenv:Envelope xmlns:soapenv="
>>>>> http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Body><axis2ns12:binary
>>>>> xmlns:axis2ns12="http://ws.apache.org/commons/ns/payload
>>>>> "></axis2ns12:binary></soapenv:Body></soapenv:Envelope>
>>>>>
>>>>> what can I do?
>>>>>
>>>>> On Fri, Jan 8, 2016 at 2:45 PM, Harsha Kumara <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hi John,
>>>>>>
>>>>>> Previous configuration I just sent for your reference. Please use
>>>>>> below. Replace values matching to your configurations.
>>>>>>
>>>>>> <api xmlns="http://ws.apache.org/ns/synapse"; name="token"
>>>>>> context="/test">
>>>>>>    <resource methods="GET" uri-template="/*">
>>>>>>       <inSequence>
>>>>>>          <property xmlns:ns="http://org.apache.synapse/xsd";
>>>>>> name="Authorization" expression="fn:concat('Basic
>>>>>> ','UEhKS1VaSjJWMUlHTU16QTYyUHpWSXppdUhFYTpfZklMQkxKMDhLQXFENmNFV3k5Y29WekE4cklh')"
>>>>>> scope="transport"/>
>>>>>>          <payloadFactory media-type="json">
>>>>>>             <format>{"grant_type":"password",
>>>>>>  "username":"admin",      "password":"admin"}  </format>
>>>>>>             <args/>
>>>>>>          </payloadFactory>
>>>>>>          <property name="messageType"
>>>>>> value="application/x-www-form-urlencoded" scope="axis2"/>
>>>>>>          <send>
>>>>>>             <endpoint>
>>>>>>                <http method="POST" uri-template="
>>>>>> https://localhost:8243/token"/>
>>>>>>             </endpoint>
>>>>>>          </send>
>>>>>>       </inSequence>
>>>>>>       <outSequence>
>>>>>>          <send/>
>>>>>>       </outSequence>
>>>>>>    </resource>
>>>>>> </api>
>>>>>>
>>>>>> Thanks,
>>>>>> Harsha
>>>>>>
>>>>>> On Sat, Jan 9, 2016 at 12:43 AM, John Q <[email protected]> wrote:
>>>>>>
>>>>>>> Hello Harsha, Thanks for your answer.
>>>>>>> I'm having problems with the code you provided me, this is what I
>>>>>>> have now:
>>>>>>>
>>>>>>> <property xmlns:ns="http://org.apache.synapse/xsd"; name=
>>>>>>> "Authorization" expression="fn:concat('Basic
>>>>>>> ','SW9Mb0ZCQ3lkaE9yVXhjQUtiTGpEVmloMU9RYTpWakhITjR2RXl5REFXVTBlbmdqZWxYeFp5M2th')"
>>>>>>>
>>>>>>> scope="transport" />
>>>>>>>
>>>>>>> <payloadFactory media-type="json">
>>>>>>>
>>>>>>> <format>
>>>>>>>
>>>>>>>           {grant_type=password&username=admin&password=admin}
>>>>>>>
>>>>>>> </format>
>>>>>>>
>>>>>>> </payloadFactory>
>>>>>>>
>>>>>>> <property name="messageType" value=
>>>>>>> "application/x-www-form-urlencoded" scope="axis2" />
>>>>>>>
>>>>>>> <call>
>>>>>>>
>>>>>>>     <endpoint>
>>>>>>>
>>>>>>>           <http method="post" uri-template="
>>>>>>> https://localhost:8243/token"; />
>>>>>>>
>>>>>>>     </endpoint>
>>>>>>>
>>>>>>> </call>
>>>>>>>
>>>>>>>
>>>>>>> The developer studio doesn't allow me to save the file, it says the
>>>>>>> username element should end with a ;
>>>>>>>
>>>>>>> could you help me with this?
>>>>>>>
>>>>>>> also, once I get the token, how can I save it to a property?
>>>>>>>
>>>>>>> I have worked with soap before, but it's my first time with rest
>>>>>>> from the ESB,
>>>>>>>
>>>>>>>
>>>>>>> Thanks again,
>>>>>>>
>>>>>>> On Fri, Jan 8, 2016 at 1:22 PM, Harsha Kumara <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi John,
>>>>>>>>
>>>>>>>> First you have to build token request within sequence and then call
>>>>>>>> the token APIs. Details about token APIs can be found in [1]. Let's 
>>>>>>>> say you
>>>>>>>> need to request a token with password grant type, then you have to 
>>>>>>>> build a
>>>>>>>> request as format specified in [2]. Below I have specified the
>>>>>>>> configuration you should write within a sequence. I haven't tested. But
>>>>>>>> format should be same. You may use call mediator instead send mediator.
>>>>>>>>
>>>>>>>>   <property xmlns:ns="http://org.apache.synapse/xsd";
>>>>>>>> name="Authorization" expression="fn:concat('Basic ','Base64 encoded
>>>>>>>> consumerKey:consumerSecret')" scope="transport" />
>>>>>>>>    <payloadFactory media-type="json">
>>>>>>>>
>>>>>>>> <format>{"grant_type=password&username=<username>&password=<password>"}
>>>>>>>>   </format>
>>>>>>>>    </payloadFactory>
>>>>>>>>    <property name="messageType"
>>>>>>>> value="application/x-www-form-urlencoded" scope="axis2" />
>>>>>>>>    <send>
>>>>>>>>       <endpoint>
>>>>>>>>          <http method="post" uri-template="
>>>>>>>> https://localhost:8243/token"; />
>>>>>>>>       </endpoint>
>>>>>>>>    </send>
>>>>>>>>
>>>>>>>> [1] - https://docs.wso2.com/display/AM1100/Token+API
>>>>>>>> [2] -
>>>>>>>> https://docs.wso2.com/display/AM1100/Generating+Access+Tokens+with+User+Credentials+-+Password+Grant+Type
>>>>>>>>
>>>>>>>> Please use dev mailing list for these type of conversations.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Harsha
>>>>>>>>
>>>>>>>> On Fri, Jan 8, 2016 at 11:28 PM, John Q <[email protected]>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>> Can any body tell me how can I get a an Api Manager Token from a
>>>>>>>>> sequence in the ESB?
>>>>>>>>>
>>>>>>>>> I know how to do it from a rest client but I don't know how to do
>>>>>>>>> the same thing from the esb using a payload mediator or whatever,
>>>>>>>>>
>>>>>>>>> thanks,
>>>>>>>>> johnq
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Architecture mailing list
>>>>>>>>> [email protected]
>>>>>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Harsha Kumara
>>>>>>>> Software Engineer, WSO2 Inc.
>>>>>>>> Mobile: +94775505618
>>>>>>>> Blog:harshcreationz.blogspot.com
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Architecture mailing list
>>>>>>>> [email protected]
>>>>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Architecture mailing list
>>>>>>> [email protected]
>>>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Harsha Kumara
>>>>>> Software Engineer, WSO2 Inc.
>>>>>> Mobile: +94775505618
>>>>>> Blog:harshcreationz.blogspot.com
>>>>>>
>>>>>> _______________________________________________
>>>>>> Architecture mailing list
>>>>>> [email protected]
>>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Architecture mailing list
>>>>> [email protected]
>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Harsha Kumara
>>>> Software Engineer, WSO2 Inc.
>>>> Mobile: +94775505618
>>>> Blog:harshcreationz.blogspot.com
>>>>
>>>> _______________________________________________
>>>> Architecture mailing list
>>>> [email protected]
>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Architecture mailing list
>>> [email protected]
>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>
>>>
>>
>>
>> --
>> Harsha Kumara
>> Software Engineer, WSO2 Inc.
>> Mobile: +94775505618
>> Blog:harshcreationz.blogspot.com
>>
>> _______________________________________________
>> Architecture mailing list
>> [email protected]
>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>
>>
>
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to