mule会话值返回null

时间:2014-09-30 20:24:17

标签: mule

<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>

来自控制台的输出:

Session Value here is-1->/qbauth

Session Value here is-2->null

我的要求是从URL获取值,插入db。我已经从url中设置了值并在会话中设置以便稍后插入到db中。但问题是,当我尝试从会话中获取值时,我获得空值。请注意,还有一个入站端点作为回调网址。 无论如何我可以保留url中的值并将其用于插入db?

2 个答案:

答案 0 :(得分:0)

会话变量不会从quickbooks授权过程传回。如果是OAuth 2,则可以使用state参数来维护请求和回调之间的状态。

然而,一种解决方案可能是在mule中使用对象存储来在流或您喜欢的任何持久性机制之间持久保存数据。并使用诸如用户名之类的独特内容来键入它。有关对象商店的更多信息:http://www.mulesoft.org/documentation/display/current/Mule+Object+Storeshttp://mulesoft.github.io/mule-module-objectstore/mule/objectstore-config.html

答案 1 :(得分:0)

您可以使用“属性”设置变量并获取回调流中的值。

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

如果要检索它,请使用

#[message.inboundProperties.test]

希望这会有所帮助。

相关问题