Sitemap

Monday, January 18, 2016

Java: WSDL to JAR

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>weatherForecast</groupId>
   <artifactId>sample-ws-client</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <name>WeatherForecast Service</name>
   <packaging>jar</packaging>
   <properties>
      <cxf.version>3.0.4</cxf.version>
   </properties>
   <build>
      <!-- maven compiler plug-ins -->
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <source>1.7</source>
               <target>1.7</target>
            </configuration>
         </plugin>
         <!-- maven wsdl2java plug-ins -->
         <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
               <execution>
                  <id>generate-sources</id>
                  <phase>generate-sources</phase>
                  <configuration>
                     <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                     <wsdlOptions>
                        <wsdlOption>
                           <wsdl>http://www.webservicex.net/WeatherForecast.asmx?WSDL</wsdl>
                        </wsdlOption>
                     </wsdlOptions>
                  </configuration>
                  <goals>
                     <goal>wsdl2java</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
   <dependencies>
      <dependency>
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-rt-frontend-jaxws</artifactId>
         <version>${cxf.version}</version>
      </dependency>
      <dependency>
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-rt-transports-http</artifactId>
         <version>${cxf.version}</version>
      </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.12</version>
      </dependency>
   </dependencies>
</project>


mvn package

Thursday, October 29, 2015

SOAPUI issue when configured with certificates

Comment the following line in <soapUI installation location>/jre/lib/security/java.security File

jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024

Monday, October 26, 2015

UCM: GET_SEARCH_RESULTS using RIDC

import java.io.IOException;

import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientException;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.model.DataObject;
import oracle.stellent.ridc.model.DataResultSet;
import oracle.stellent.ridc.model.serialize.HdaBinderSerializer;
import oracle.stellent.ridc.protocol.ServiceResponse;

public class TestRIDCSearch {
    public static void main(String[] args) {
        IdcClientManager manager = new IdcClientManager();
        try {
            IdcClient idcClient = manager.createClient("idc://localhost:4444");
            IdcContext userContext = new IdcContext("sysadmin");
            HdaBinderSerializer serializer = new HdaBinderSerializer("UTF-8", idcClient.getDataFactory());

            DataBinder dataBinder = idcClient.createBinder();
            dataBinder.putLocal("IdcService", "GET_SEARCH_RESULTS");
            
            /*The easiest way to figure out the QueryText expected by the content server is to execute the query using the content server search screen 
            in the native UI and trace that call. Gather full verbose, system audit trace using the following trace sections:
            system, requestaudit, searchquery, searchcache
            This should be the following output:
            >searchquery/6 03.25 14:24:41.285 IdcServer-826 preparedQueryText: ( dDocName `test` dSecurityGroup `Public` dInDate >= `3/25/15 12:00 AM` )*/
            
            /*NOTE: UCM limits the ResultCount value according to the MaxResults configuration setting for Content Server. 
             * To increase the MaxResults setting, add the setting MaxResults=<integer> in config.cfg*/
            
            dataBinder.putLocal("QueryText", "dDocName `test` dSecurityGroup `Public` dInDate >= `3/25/15 12:00 AM`");
            serializer.serializeBinder(System.out, dataBinder);
            ServiceResponse response = idcClient.sendRequest(userContext, dataBinder);

            DataBinder responseData = response.getResponseAsBinder();
            serializer.serializeBinder(System.out, responseData);
            DataResultSet resultSet = responseData.getResultSet("SearchResults");

            for (DataObject dataObject : resultSet.getRows()) {
                System.out.println("Title is: " + dataObject.get("dDocTitle"));
            }
        } catch (IdcClientException ice) {
            ice.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}


Installation of multiple versions of JDeveloper

Navigate to <Installation_Folder>\jdeveloper\jdev\bin\jdev.boot file.

Locate the ide.user.dir property and change it to something like this:
ide.user.dir= C:/JDev11117SOADefaultDomain

Friday, October 9, 2015

Prerequisites before SOA Development

Creation of JMS Queue
Queue: Defines a point-to-point destination type, which are used for asynchronous peer communications. A message delivered to a queue is distributed to only one consumer.

Click SOAJMSModule.


In the Summary of Resources table, click New. Select the resource type: Queue and click Next.

Enter name: demoFulfillmentQueue and JNDI name: jms/demoFulfillmentQueue

Select Subdeployment SOASubDeployment. Select JMS Server SOAJMSServer

Creation of Connection Factory
Connection Factory: Defines a set of connection configuration parameters that are used to create connections for JMS clients.

Select the resource type: Connection Factory and click Next
Enter name: demoCF and JNDI name: jms/demoCF.

You should see both the queue and the connection factory listed in the Summary of Resources as shown here.

Now add the connection pool. The connection pool is configured in the JMSAdapter application and uses a Deployment Plan. First, create a directory to contain that plan.

Create a directory JMSPlan: C:\Oracle\Oracle_SOA1\soa\JMSPlan

Click Deployments. Click JMS Adapter. Click the Configuration tab and then the Outbound Connection Pools tab.

Click New. Select the factory oracle.tip.adapter.jms.IJmsConnectionFactory. Click Next. Enter eis/Queue/demo.

Click on eis/Queue/demo. Change the property ConnectionFactoryLocation to value jms/demoCF. Now update the JMSAdapter adapter.

=====================================================================

Create a data source with name as soademoDatabase, and JNDI Name as jdbc/soademoDatabase

Create a directory DBPlan: C:\Oracle\Oracle_SOA1\soa\DBPlan

Click Deployments. Click DbAdapter. Click the Configuration tab and then the Outbound Connection Pools tab.

Enter the JNDI Name as follows: eis/DB/soademoDatabase

Edit the connection pool to reference the data source. You have created a connection pool.

Monday, September 21, 2015

SOA Glossary

Service Component Architecture (SCA)
Service Component Architecture (SCA) is a set of specifications that describe a model for building applications using a service-oriented architecture.
1. Services are assembled together to form a composite application that creates a solution that addresses a specific business requirement.
2. Composite applications may contain new services (specifically for the application) and business functions from existing systems and applications (reused in the composite application).


SOA Composite
A SOA composite is an assembly of services, service components, and references designed and deployed together in a single application. Wiring between the service, service component, and reference enables message communication.
  1. Services provide the outside world with an entry point to the SOA composite application. The service advertises its capabilities (also known as operations) to external applications with a WSDL (Web Services Description Language) file. The binding of the service describes the protocols that can communicate with the application. Examples include SOAP/HTTP or a JCA adapter.
  2. Service components are the building blocks of a SOA composite application. Oracle SOA Suite 11g includes the following components:
    - The BPEL Process component enables design and execution of a business process that integrates a series of business activities and services into an end-to-end process flow.
    - The Business Rules component provides the means of making business decisions based on defined rules.
    - The Human Task component allows you to model a workflow that describes tasks for users or groups to perform as part of an end-to-end business process flow.
    - The Mediator component is used for validation, filtering, transformation, and routing of message data between components.
  3. References enable messages to be sent from the SOA composite application to external services in the outside world.

Service Data Object (SDO)

An SDO exposes any data source as a service, which enables retrieval and manipulation of the data in an XML format through service operations. The task of connecting applications to data sources is performed by a data mediator service.
Oracle SOA Suite 11g enables a BPEL Process to access an SDO through an Entity Variable, a special type of BPEL variable associated with a SDO as a service. Oracle ADF-BC components can be deployed simultaneously as Web Service and an SDO.


WSIL (Web Services Inspection Language) Connection
The http://localhost:8001/inspection.wsil URL accesses a Java EE application that dynamically discovers WSDL URL endpoints for Java EE and SOA composite applications deployed to the same run-time server.


Adapters
Adapters provide a service interface that:
• Exposes external application functionality in a form that can be used by SOA composite application components
• Converts request and responses into a form suitable for other (external) systems
• Implements interfaces by using the Java Connector Architecture (JCA) API standards


Oracle Web Service Manager Policy Manager Policy Manager

Oracle WSM  Policy Manager provides the infrastructure for enforcing global security and auditing policies in the service infrastructure. By securing various endpoints and setting and propagating identity, it secures applications. Oracle WSM Policy Manager provides a standard mechanism for signing messages, performing encryption, performing authentication, and providing role-based access control.


The Oracle Metadata Repository

The Oracle SOA Suite 11g runtime environment requires MDS to maintain SOA application configuration and runtime information. It is used to manage deployed services and composite applications.
The MDS can also be used as a central location for storing and referencing shared service artifacts, such as business events, rule sets for Oracle Business Rules, XSLT files for Oracle Mediator, XSD and WSDL documents for Oracle BPEL Process Manager, and other service documents, which can be deployed in a sharable archive format known as the Metadata archive (.mar files).


Business Events and the Event Delivery Network

A business event is a way for one application to notify another application of a significant occurrence to the business. When a business event is published, another application (or service component) can subscribe to it and initiate whatever processing is implied by that event. For example, when product stock levels are updated in an inventory database, an event can serve as a trigger or signal for another process to fulfill orders that have been on hold until products become available.
Business events are typically an asynchronous fire-and-forget (one-way) notification of a business occurrence.
Events are defined by using Event Definition Language (EDL) to specify the name and structure of an event. Definitions for business events are stored in the MDS, and published in the Event Delivery Network (EDN).
The Event Delivery Network is designed to handle asynchronous messaging arising from a business or system event. The EDN is not messaging infrastructure. It provides an application with a declarative publish-subscribe implementation to publish events so that a composite application with a Mediator component can subscribe to events that trigger execution of the composite application.

Wednesday, September 16, 2015

SOAP-based web service in Java

TimeServer.java
package com.sonal;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

/**
 * SEI for a web service that returns the current time as either a string or as
 * the elapsed milliseconds from the Unix epoch, midnight January 1, 1970 GMT.
 * 
 * The annotation @WebService signals that this is the SEI (Service Endpoint
 * Interface). @WebMethod signals that each method is a service operation.
 *
 * The @SOAPBinding annotation impacts the under-the-hood construction of the
 * service contract, the WSDL (Web Services Definition Language) document.
 */
@WebService
@SOAPBinding(style = Style.DOCUMENT)
public interface TimeServer {
 @WebMethod
 String getTimeAsString();

 @WebMethod
 long getTimeAsElapsed();
}


TimeServerImpl.java
package com.sonal;

import java.util.Date;
import javax.jws.WebService;

/**
 * The @WebService property endpointInterface links this SIB (Service
 * Implementation Bean) to the SEI (com.sonal.TimeServer). Note that the method
 * implementations are not annotated as @WebMethods.
 */
@WebService(endpointInterface = "com.sonal.TimeServer")
public class TimeServerImpl implements TimeServer {
 public String getTimeAsString() {
  return new Date().toString();
 }

 public long getTimeAsElapsed() {
  return new Date().getTime();
 }
}


TimeServerPublisher.java
package com.sonal;

import javax.xml.ws.Endpoint;

/**
 * This application publishes the web service whose SIB is
 * com.sonal.TimeServerImpl. For now, the service is published at network address
 * 127.0.0.1., which is localhost, and at port number 9876, as this port is
 * likely available on any desktop machine. The publication path is /ts, an
 * arbitrary name.
 *
 * The Endpoint class has an overloaded publish method. In this two-argument
 * version, the first argument is the publication URL as a string and the second
 * argument is an instance of the service SIB, in this case
 * com.sonal.TimeServerImpl.
 *
 * The application runs indefinitely, awaiting service requests. It needs to be
 * terminated at the command prompt with control-C or the equivalent.
 *
 * Once the application is started, open a browser to the URL
 *
 ** http://127.0.0.1:9876/ts?wsdl
 *
 * to view the service contract, the WSDL document. This is an easy test to
 * determine whether the service has deployed successfully. If the test
 * succeeds, a client then can be executed against the service.
 */

public class TimeServerPublisher {
 public static void main(String[] args) {
  // 1st argument is the publication URL
  // 2nd argument is an SIB instance
  Endpoint.publish("http://127.0.0.1:9876/ts", new TimeServerImpl());
 }
}



WSDL document for the TimeServer service
<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01. -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01. -->
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://sonal.com/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://sonal.com/" name="TimeServerImplService">
   <types>
      <xsd:schema>
         <xsd:import namespace="http://sonal.com/" schemaLocation="http://127.0.0.1:9876/ts?xsd=1" />
      </xsd:schema>
   </types>
   <message name="getTimeAsString">
      <part name="parameters" element="tns:getTimeAsString" />
   </message>
   <message name="getTimeAsStringResponse">
      <part name="parameters" element="tns:getTimeAsStringResponse" />
   </message>
   <message name="getTimeAsElapsed">
      <part name="parameters" element="tns:getTimeAsElapsed" />
   </message>
   <message name="getTimeAsElapsedResponse">
      <part name="parameters" element="tns:getTimeAsElapsedResponse" />
   </message>
   <portType name="TimeServer">
      <operation name="getTimeAsString">
         <input wsam:Action="http://sonal.com/TimeServer/getTimeAsStringRequest" message="tns:getTimeAsString" />
         <output wsam:Action="http://sonal.com/TimeServer/getTimeAsStringResponse" message="tns:getTimeAsStringResponse" />
      </operation>
      <operation name="getTimeAsElapsed">
         <input wsam:Action="http://sonal.com/TimeServer/getTimeAsElapsedRequest" message="tns:getTimeAsElapsed" />
         <output wsam:Action="http://sonal.com/TimeServer/getTimeAsElapsedResponse" message="tns:getTimeAsElapsedResponse" />
      </operation>
   </portType>
   <binding name="TimeServerImplPortBinding" type="tns:TimeServer">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
      <operation name="getTimeAsString">
         <soap:operation soapAction="" />
         <input>
            <soap:body use="literal" />
         </input>
         <output>
            <soap:body use="literal" />
         </output>
      </operation>
      <operation name="getTimeAsElapsed">
         <soap:operation soapAction="" />
         <input>
            <soap:body use="literal" />
         </input>
         <output>
            <soap:body use="literal" />
         </output>
      </operation>
   </binding>
   <service name="TimeServerImplService">
      <port name="TimeServerImplPort" binding="tns:TimeServerImplPortBinding">
         <soap:address location="http://127.0.0.1:9876/ts" />
      </port>
   </service>
</definitions>

The portType section, near the top, groups the operations that the web service delivers, in this case the operations getTimeAsString and getTimeAsElapsed, which are the two Java methods declared in the SEI and implemented in the SIB. The WSDL portType is like a Java interface in that the portType presents the service operations abstractly but provides no implementation detail.
The other WSDL section of interest is the last, the service section, and in particular the service location, in this case the URL http://localhost:9876/ts. The URL is called the service endpoint and it informs clients about where the service can be accessed.

TimeClient.java
package com.sonal;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.URL;

class TimeClient {
 public static void main(String args[]) throws Exception {
  URL url = new URL("http://localhost:9876/ts?wsdl");
  // Qualified name of the service:
  // 1st arg is the service URI
  // 2nd is the service name published in the WSDL
  QName qname = new QName("http://sonal.com/", "TimeServerImplService");
  // Create, in effect, a factory for the service.
  Service service = Service.create(url, qname);
  // Extract the endpoint interface, the service "port".
  TimeServer port = service.getPort(TimeServer.class);
  System.out.println(port.getTimeAsString());
  System.out.println(port.getTimeAsElapsed());
 }
}