Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note

When building the sample using the source ensure you update pom.xml with the online repository. To do this, add the following section before <dependencies>tag in pom.xml:

Code Block
<repositories>
	<repository>
	   <id>wso2-nexus</id>
	   <name>WSO2 internal Repository</name>
	   <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
	   <releases>
		  <enabled>true</enabled>
		  <updatePolicy>daily</updatePolicy>
		  <checksumPolicy>ignore</checksumPolicy>
	   </releases>
	 </repository>
	 <repository>
	   <id>wso2-maven2-repository</id>
	   <name>WSO2 Maven2 Repository</name>
	   <url>http://dist.wso2.org/maven2</url>
	   <snapshots>
	     <enabled>false</enabled>
	   </snapshots>
	   <releases>
		 <enabled>true</enabled>
		 <updatePolicy>never</updatePolicy>
		 <checksumPolicy>fail</checksumPolicy>
	   </releases>
	</repositoryrepository>
</repositories>

Alternatively, you can download the JAR file from the following location, copy it to the <EI_HOME>/lib directory, and restart WSO2 EI:

...

  1. In WSO2 EI Management Console, go to Manage -> Service Bus and click Source View.
  2. Insert the following XML configuration into the source view before the closing </definitions> tag to create the TestGoogle API:

    Code Block
    languagehtml/xml
     <api xmlns="http://ws.apache.org/ns/synapse"
         name="TestGoogle"
         context="/search">
       <resource methods="GET">
          <inSequence>
             <log level="full">
               <property name="STATUS" value="***** REQUEST HITS IN SEQUENCE *****"/>
             </log>
             <send>
                <endpoint>
                   <http method="get" uri-template="https://www.google.lk/search?q=wso2"/>
                </endpoint>
             </send>
          </inSequence>
       </resource>
       <handlers>
           <handler class="org.wso2.handler.SimpleOAuthHandlerSimpleOauthHandler"/>
       </handlers>
    </api>

    Notice that the <handlers> tag contains the reference to the custom handler class.

  3. Copy the custom handler.jar to the <EI_HOME>/lib directory.
  4. Open <EI_HOME>/repository/axis2/axis2.xml and add the following parameters:

    Code Block
    languagehtml/xml
    <!-- OAuth2 Token Validation Service -->
    <parameter name="oauth2TokenValidationService">https://localhost:9444/services/OAuth2TokenValidationService</parameter>
    <!-- Server credentials -->
    <parameter name="identityServerUserName">admin</parameter>
    <parameter name="identityServerPw">admin</parameter>
  5. Restart WSO2 EI.

...

To test this API configuration, you must run the SecureStockQuoteService, which is bundled in the samples folder, as the back-end server. Start this sample as described in Setting Up the ESB Samples. Because this This sample uses Apache Rampart for as the back-end security implementation. Therefore, you might also need to download and install the unlimited strength policy files for your JDK before using Apache Rampart.

To download and install the unlimited strength policy files:

  1. Go to to http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html, and download the unlimited the unlimited strength JCE policy files for your JDK version.
  2. Extract Uncompress and extract the downloaded ZIP . You will now have two JAR files: file. This creates a directory named JCE that contains the local_policy.jar and  and US_export_policy.jar files.
  3. In your Java installation directory, go to the the jre/lib/security directory, such as: /usr/java/jdk1.8.0_65/jre/lib/security.Make a backup of the files  directory, make a copy of the existing local_policy.jar and  and US_export_policy.jar files, and then replace them the original policy files with the ones downloaded from the JCE ZIP filepolicy files you extracted in the previous step.

Now that you have set up the API and the secured back-end SOAP service, you are ready to test this configuration with the following curl command.

...