wso2esb身份验证服务异常

时间:2015-09-09 11:54:55

标签: wso2 axis2 wso2esb wso2is wso2carbon

我已将wso2esb 4.7.0升级到wso2esb 4.8.0

我有一个登录服务,它将对用户名和密码进行身份验证并返回true或false,它在4.7.0版本中工作正常,但在4.8.0版本中它无效。

当从任何其他代理内部调用此服务时,它为该代理的有效用户返回true,但是当我直接调用它时,它返回null并在esb中抛出错误,如下所示。

ERROR {org.apache.axis2.transport.base.threads.NativeWorkerPool} -  Uncaught exception {org.apache.axis2.transport.base.threads.NativeWorkerPool}
java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMElementImpl cannot be cast to org.apache.axiom.soap.SOAPFault
    at org.apache.axiom.soap.impl.llom.SOAPBodyImpl.getFault(SOAPBodyImpl.java:120)
    at org.apache.synapse.util.POXUtils.convertSOAPFaultToPOX(POXUtils.java:46)
    at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:93)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:321)
    at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:94)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
    at org.apache.synapse.mediators.filters.FilterMediator.mediate(FilterMediator.java:160)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:261)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:486)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:225)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:701)

使用curl直接执行

curl -v -H "Accept: application/json" -H "Content-Type:application/json" -d '{"username":"vikash|214057357158656","password":"gbadmin"}' http://redmine.youtility.in:8282/services/ServiceLogin2.0

axix2.xml消息格式化程序和构建器

 <messageFormatter contentType="application/json" 
class="org.apache.axis2.json.JSONMessageFormatter"/>

<messageFormatter contentType="application/json/badgerfish"                              
    class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>

<messageBuilder contentType="application/json"                            
    class="org.apache.axis2.json.JSONBuilder"/>

<messageBuilder contentType="application/json/badgerfish"                            
    class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>

代理

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ServiceLogin2.0"
       transports="https http"
       statistics="enable"
    startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence onError="fault">
         <property name="messageType" value="application/json" scope="axis2"/>
         <property name="client_ip_address"
                   expression="get-property('axis2','REMOTE_ADDR')"
                   scope="default"
                   type="STRING"/>
         <property name="username"
                   expression="//username/text()"
                   scope="default"
                   type="STRING"/>
         <property name="password"
                   expression="//password/text()"
                   scope="default"
                   type="STRING"/>
         <property name="usercode"
                   expression="fn:substring-before(get-property('username'),'|')"
                   scope="default"
                   type="STRING"/>
         <property name="clientid"
                   expression="fn:substring-after(get-property('username'),'|')"
                   scope="default"
                   type="STRING"/>
         <property name="requestMsgId"
                   expression="get-property('MessageID')"
                   scope="default"
                   type="STRING"/>
         <log level="custom">
            <property name="LogLocation" value="ServiceLogin2.0"/>
            <property name="Usercode" expression="get-property('usercode')"/>
            <property name="Clientid" expression="get-property('clientid')"/>
            <property name="requestMsgId" expression="get-property('requestMsgId')"/>
         </log>
         <payloadFactory>
            <format>
               <p:login xmlns:p="http://authentication.services.core.carbon.wso2.org">
                  <p:username>$1</p:username>
                  <p:password>$2</p:password>
                  <p:remoteAddress>$3</p:remoteAddress>
               </p:login>
            </format>
            <args>
               <arg evaluator="xml" expression="//username/text()"/>
               <arg evaluator="xml" expression="//password/text()"/>
               <arg evaluator="xml" expression="get-property('client_ip_address')"/>
            </args>
         </payloadFactory>
         <header name="Action" value="urn:login"/>
         <send receive="ServiceLogin_Seq2.0">
            <endpoint>
               <address uri="https://localhost:9443/services/AuthenticationAdmin"
                        format="soap11">
                  <suspendOnFailure>
                     <errorCodes>101500,101501,101506,101507,101508,101503,50000</errorCodes>
                     <initialDuration>30</initialDuration>
                     <progressionFactor>1.0</progressionFactor>
                     <maximumDuration>300</maximumDuration>
                  </suspendOnFailure>
               </address>
            </endpoint>
         </send>
      </inSequence>
      <outSequence onError="fault">
         <send/>
      </outSequence>
   </target>
</proxy>

序列:

<sequence xmlns="http://ws.apache.org/ns/synapse"
          name="ServiceLogin_Seq2.0"
          onError="fault" statistics="enable">
   <property name="messageType" value="application/json" scope="axis2"/>
   <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
   <property name="HTTP_METHOD" value="POST" scope="axis2"/>
   <property name="RESPONSE" value="true" scope="default" type="STRING"/>
   <property xmlns:ns="http://org.apache.synapse/xsd"
             xmlns:p="http://authentication.services.core.carbon.wso2.org"
             name="Return"
             expression="//p:return/text()"
             scope="default"
             type="STRING"/>

<filter xmlns:ns="http://org.apache.synapse/xsd" xpath="get-property('Return')=''">
      <then>
         <payloadFactory>
            <format>
               <ResponseJSON xmlns="">
                  <Authentication>$1</Authentication>
                  <Exception>Service trying to connect inactive service</Exception>
                  <Status>101503</Status>
               </ResponseJSON>
            </format>
            <args>
               <arg evaluator="xml" expression="get-property('Return')"/>
            </args>
         </payloadFactory>
         <send/>
      </then>
      <else>
         <filter xpath="get-property('Return')='false'">
            <then>
               <payloadFactory>
                  <format>
                     <ResponseJSON xmlns="">
                        <Authentication>$1</Authentication>
                        <Exception>Authentication Failed</Exception>
                        <Status>401</Status>
                     </ResponseJSON>
                  </format>
                  <args>
                     <arg evaluator="xml" expression="get-property('Return')"/>
                  </args>
               </payloadFactory>
               <send/>
            </then>
            <else>
               <payloadFactory>
                  <format>
                     <ResponseJSON xmlns="">
                        <Body>
                           <Datalist>
                              <Authentication>$1</Authentication>
                          </Datalist>
                        </Body>
                     </ResponseJSON>
                  </format>
                  <args>
                  <arg evaluator="xml" expression="get-property('Return')"/>
                  </args>
               </payloadFactory>
               <send/>
            </else>
         </filter>
      </else>
   </filter>
<log level="custom">          
        <property name="LogLocation" value="ServiceLogin_Seq2.0"/>
        <property name="Usercode" expression="get-property('usercode')"/>
            <property name="Clientid" expression="get-property('clientid')"/>
            <property name="requestMsgId" expression="get-property('requestMsgId')"/>
            <property name="responseMsgId" expression="get-property('MessageID')"/>
         </log>
</sequence>

0 个答案:

没有答案