2014-09-30 28 views
0
<flow name="authenticateqbFlow1" doc:name="authenticateqbFlow1"> 
    <http:inbound-endpoint exchange-pattern="request-response" host="${hostname}" port="${port}" path="qbauth" doc:name="HTTP"/> 
    <set-session-variable variableName="test" value="#[payload]" doc:name="Access token Session Variable"/> 
    <quickbooks:auth-user config-ref="QBAuthenticate" 
      accessTokenUrl="https://oauth.intuit.com/oauth/v1/get_access_token" 
      authorizationUrl="https://appcenter.intuit.com/Connect/Begin" 
      callbackUrl="http://${hostname}:${port}/auth" 
      requestTokenUrl="https://oauth.intuit.com/oauth/v1/get_request_token" 
      doc:name="Authenticate user" requestTokenId="tenantId"/> 
    <logger message="Session Value here is-1->#[sessionVars['test']]" level="INFO" doc:name="Logger"/> 
</flow> 
<flow name="authenticateqbFlow2" doc:name="authenticateqbFlow2"> 
    <http:inbound-endpoint exchange-pattern="request-response" host="${hostname}" port="${port}" path="auth" doc:name="HTTP"/> 
    <logger message="Session Value here is-2->#[sessionVars['test']]" level="INFO" doc:name="Logger"/> 
    <quickbooks:get-access-token config-ref="QBAuthenticate" doc:name="Quickbooks Online"/>   
    <set-payload value="Authentication: Success" doc:name="Set Payload"/> 
</flow> 

輸出:騾子會話值從控制檯返回null

Session Value here is-1->/qbauth 

Session Value here is-2->null 

我的要求是從URL中獲得的價值,插入數據庫。我已經把url中的值和session設置爲稍後插入到db中。但問題是,當我嘗試從會話中獲取值時,我得到了空值。請注意,還有一個入站端點作爲回叫網址。 是否有反正我可以保持URL的值,並將其用於插入到分貝?

+0

這是你的完整配置文件。我看不到任何代碼插入到數據庫中。兩種流量之間也沒有聯繫。從第一個流程調用第二個流程(讀取會話變量的地方)是怎樣的? – user1760178 2014-09-30 20:34:38

+0

@ user1760178,是的,它是完整的流程。插入數據庫我已經刪除,因爲我無法獲得會話值。使用回調url調用第二個流:callbackUrl =「http:// $ {hostname}:$ {port}/auth」。 – bekur 2014-09-30 20:40:01

回答

0

會話變量不會從quickbooks授權過程傳回。如果它是OAuth 2,則可以使用狀態參數來維護請求和回調之間的狀態。

然而,一種解決方案可能是使用mule中的Object Stores在流之間持久存儲數據或者您喜歡的任何持久性機制。例如,使用諸如用戶名等獨特的密鑰。更多關於對象存儲在這裏:http://www.mulesoft.org/documentation/display/current/Mule+Object+Storeshttp://mulesoft.github.io/mule-module-objectstore/mule/objectstore-config.html

+0

你是否知道任何示例應用程序需要共享哪些與上述情況非常相似?很難理解mule ref文檔。 – bekur 2014-09-30 21:39:24

+0

Theres在github上的一個例子。 https://github.com/mulesoft/mule-module-objectstore/blob/master/demo/src/main/app/ObjectStoreDemo.xml如果您將:store部分放入第一個流中。並在您的第二個流程 – 2014-09-30 21:49:03

0

您可以使用屬性來設置你的varaible並獲得在回調流量值。

<set-property propertyName="test" value="#[payload]" doc:name="Property"/> 

當你想找回它使用

#[message.inboundProperties.test] 

希望這有助於。

+0

我試過這個檢索,它給了空值#[message.inboundProperties.test]。因爲它有一個回調url,其行爲像新的請求 – bekur 2014-09-30 21:42:00