2017-01-27 11 views

답변

2

나는 당신이 응답

여기에 구현

<api xmlns="http://ws.apache.org/ns/synapse" name="showById" context="/getById"> 
    <resource methods="POST GET" uri-template="/getEmployeeXML/{Id}"> 
     <inSequence> 
     <property name="getId" expression="get-property('uri.var.Id')" scope="default" type="STRING"/> 
     <log> 
      <property name="ID" expression="get-property('getId')"/> 
     </log> 
     <property name="Accept" value="application/json" scope="transport" type="STRING"/> 
     <property name="messageType" value="application/json" scope="axis2"/> 
     <payloadFactory media-type="xml"> 
      <format> 
       <p:getEmployeeXML xmlns:p="arce.farmacy"> 
        <xs:Id xmlns:xs="arce.farmacy">$1</xs:Id> 
       </p:getEmployeeXML> 
      </format> 
      <args> 
       <arg evaluator="xml" expression="get-property('getId')"/> 
      </args> 
     </payloadFactory> 
     <property name="Action" value="urn:getEmployeeXML" scope="transport" type="STRING"/> 
     <property name="SOAPAction" value="urn:getEmployeeXML" scope="transport" type="STRING"/> 
     <property name="REST_URL_POSTFIX" scope="axis2" action="remove"/> 
      <send> 
      <endpoint> 
       <address uri="http://169.254.193.10:9763/services/StoreProcedureFarmacy" format="soap11"/> 
      </endpoint> 
     </send> 
     </inSequence> 
     <outSequence> 
     <log level="full"/> 
     <send/> 
     </outSequence> 
     <faultSequence> 
     <sequence key="{faultSEQ}"/> 
     </faultSequence> 
    </resource> 
</api> 

을 볼 수 있습니다

<property name="Accept" value="application/json" scope="transport" type="STRING"/> 
<property name="messageType" value="application/json" scope="axis2"/> 

이 두 가지 속성을 사용하여 JSON으로 응답을 얻을 수 있습니다

{ 
    "Employees": { 
    "Employe": [ 
     { 
     "Id": 5, 
     "Description": "Office 2" 
     } 
    ] 
    } 
}