Question

I have created the following WSO2 Data Server Service.

    <?xml version="1.0" encoding="UTF-8"?>
   <data name="Codelists" serviceGroup="test group" serviceNamespace="********">  
      <description></description>  
      <config id="codelist-DS">    
         <property name="org.wso2.ws.dataservice.driver">com.mysql.jdbc.Driver</property>    
         <property name="org.wso2.ws.dataservice.protocol">jdbc:mysql://localhost:3306/codelists_db</property>    
         <property name="org.wso2.ws.dataservice.user">*****</property>    
         <property name="org.wso2.ws.dataservice.password">*****</property>  
      </config>  
      <query id="getCodeListsSQL" useConfig="codelist-DS">    
         <sql>SELECT CL, MASTER_CL, DESCR, EXTRA1, EXTRA2, EXTRA3, COMMENT FROM CODE_LIST</sql>    
         <result element="codelists" rowName="codelist">      
            <element column="CL" name="number" xsdType="xs:integer"/>      
            <element column="MASTER_CL" name="master-codelist" xsdType="xs:integer"/>      
            <element column="DESCR" name="description" xsdType="xs:string"/>      
            <element column="EXTRA1" name="extra1" xsdType="xs:string"/>      
            <element column="EXTRA2" name="extra2" xsdType="xs:string"/>      
            <element column="EXTRA3" name="extra3" xsdType="xs:string"/>      
            <element column="COMMENT" name="comment" xsdType="xs:string"/>      
            <call-query href="getCodeValueSQL">        
               <with-param column="CL" name="cl"/>      
            </call-query>    
         </result>  
      </query>  
      <query id="getCodeListSQL" useConfig="codelist-DS">    
         <sql>SELECT CL, MASTER_CL, DESCR, EXTRA1, EXTRA2, EXTRA3, COMMENT FROM CODE_LIST WHERE CL=:cl</sql>    
         <result element="codelists" rowName="codelist">      
            <element column="CL" name="number" xsdType="xs:integer"/>      
            <element column="MASTER_CL" name="master-codelist" xsdType="xs:integer"/>      
            <element column="DESCR" name="description" xsdType="xs:string"/>      
            <element column="EXTRA1" name="extra1" xsdType="xs:string"/>      
            <element column="EXTRA2" name="extra2" xsdType="xs:string"/>      
            <element column="EXTRA3" name="extra3" xsdType="xs:string"/>      
            <element column="COMMENT" name="comment" xsdType="xs:string"/>      
            <call-query href="getCodeValueSQL">        
               <with-param name="cl" query-param="cl"/>      
            </call-query>    
         </result>    
         <param name="cl" sqlType="STRING"/>  
      </query>  
      <query id="getCodeValueSQL" useConfig="codelist-DS">    
         <sql>SELECT ID, VALUE, CODE_LIST_NUM, MASTER_VALUE, DESCR, VALUE_ORDER, COMMENT, DISPLAY_TYPE, EXTRA1, EXTRA2, EXTRA3, VALID_FROM, VALID_TO, STATUS_CODE, DATA_SOURCE, LAST_MODIFIED FROM CODE_VALUE WHERE CODE_LIST_NUM=:cl</sql>    
         <result element="items" rowName="item">      
            <element column="ID" name="id" xsdType="xs:integer"/>      
            <element column="VALUE" name="value" xsdType="xs:string"/>      
            <element column="CODE_LIST_NUM" name="codelist-number" xsdType="xs:integer"/>      
            <element column="MASTER_VALUE" name="master-value" xsdType="xs:string"/>      
            <element column="DESCR" name="description" xsdType="xs:string"/>      
            <element column="VALUE_ORDER" name="value-order" xsdType="xs:integer"/>      
            <element column="COMMENT" name="comment" xsdType="xs:string"/>      
            <element column="DISPLAY_TYPE" name="display-type" xsdType="xs:integer"/>      
            <element column="EXTRA1" name="extra1" xsdType="xs:string"/>      
            <element column="EXTRA2" name="extra2" xsdType="xs:string"/>      
            <element column="EXTRA3" name="extra3" xsdType="xs:string"/>      
            <element column="VALID_FROM" name="valid-from" xsdType="xs:date"/>      
            <element column="VALID_TO" name="valid-to" xsdType="xs:date"/>      
            <element column="STATUS_CODE" name="status-code" xsdType="xs:string"/>      
            <element column="DATA_SOURCE" name="data-source" xsdType="xs:date"/>      
            <element column="LAST_MODIFIED" name="last-modified" xsdType="xs:dateTime"/>    
         </result>    
         <param name="cl" sqlType="INTEGER"/>  
      </query>  
      <resource method="GET" path="codelist/{cl}">    
         <call-query href="getCodeListSQL">      
            <with-param name="cl" query-param="cl"/>    
         </call-query>  
      </resource>  
      <resource method="GET" path="codelists">    
         <call-query href="getCodeListsSQL"/>  
      </resource>
   </data>

I would like to use this service through wso2 ESB. However I can't get it working. How should I expose the service in ESB and what type of security should I apply? Could you give me some reference guide?

I've tried the following ESB configuration:

<proxy name="Codelists" transports="https" startOnLoad="true" trace="disable">
    <target>
        <endpoint>
            <address uri="http://localhost:9446/services/Codelists"/>
        </endpoint>
        <outSequence>
            <send/>
        </outSequence>
    </target>
    <publishWSDL uri="https://localhost:9446/services/Codelists?wsdl"/>
    <policy key="conf:/repository/axis2/service-groups/Codelists/services/Codelists/policies/UTOverTransport"/>
    <enableSec/>
</proxy>

But with this configuration when I use the "TryIt" feature I get either an authorization error or this:

    [2012-08-02 10:03:50,966]  WARN - ClientHandler I/O error : Connection reset by peer For : 127.0.0.1:9446 For Request : Axis2Request [Message ID : urn:uuid:57d99ccc-9dde-428b-bfdb-73f87276a491] [Status Completed : false] [Status SendingCompleted : true]
[2012-08-02 10:03:50,967]  WARN - EndpointContext Endpoint : endpoint_8196419801b8a9afd598ca65d60b30bbbe9d6abaf3e21ab2 will be marked SUSPENDED as it failed
[2012-08-02 10:03:50,967]  WARN - EndpointContext Suspending endpoint : endpoint_8196419801b8a9afd598ca65d60b30bbbe9d6abaf3e21ab2 - last suspend duration was : 30000ms and current suspend duration is : 30000ms - Next retry after : Thu Aug 02 10:04:20 EEST 2012
Was it helpful?

Solution

  • Check whether you can tryit the created data service using the dataservices tryit ui.
  • If so, you can simply create a passthru proxy(without enabling security) and try invoking the same service via ESB.
  • If you want to expose that proxy service as a secured service, you can simple enable security and select a suitable security scenario out of the 16 security scenarios available.
  • Please refer http://wso2.org/project/esb/java/4.0.3/docs/ for more info
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top