Commit 2eabc83c authored by Nicolas Dolet's avatar Nicolas Dolet

New example using web services for checking the validity of an email address.

parent a4e17cf5
<?xml version="1.0"?>
<!--
* OW2 FraSCAti Examples: Verify Mail
*
* Copyright (c) 2009 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author: Nicolas Dolet
-->
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.ow2.frascati.examples</groupId>
<artifactId>verifymail</artifactId>
<version>0.6-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Verify mail</name>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>${java.specification.version}</target>
</configuration>
</plugin>
<!--
CXF maven plugin which allow to generate java interface from
WSDL
-->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/XWebEmailValidation.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
Compile the weather SCA composite with the SCOrWare Generate
Factory.
-->
<plugin>
<groupId>org.ow2.frascati.factory</groupId>
<artifactId>frascati-factory-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>generate-factory</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<factory>GenerateFactory</factory>
<srcs>
<src>src/main/java</src>
<src>src/main/resources</src>
<src>target/generated/src/main/java</src>
</srcs>
<composite>verifymail.composite</composite>
</configuration>
</plugin>
</plugins>
</build>
<!-- ============= -->
<!-- Repositories -->
<!-- ============= -->
<repositories>
<!-- ObjectWeb Release Repository -->
<repository>
<id>objectweb-release</id>
<name>ObjectWeb Maven Repository</name>
<url>http://maven.objectweb.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Apache -->
<repository>
<id>apache-incubating</id>
<url>http://people.apache.org/repo/m2-incubating-repository</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases />
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>objectweb-release</id>
<name>ObjectWeb Maven Repository</name>
<url>http://maven.objectweb.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-sca-api</artifactId>
<version>1.2.1-incubating</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.2.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-activation_1.1_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
/***
* OW2 FraSCAti Assembly Factory Examples: Verify mail
* Copyright (C) 2009 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Nicolas Dolet
*/
package org.ow2.frascati.examples.verifymail;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.osoa.sca.annotations.Reference;
import com.xwebservices.ws.xwebemailvalidation.emailvalidation.v2.XWebEmailValidationInterface;
import com.xwebservices.ws.xwebemailvalidation.emailvalidation.v2.messages.ObjectFactory;
import com.xwebservices.ws.xwebemailvalidation.emailvalidation.v2.messages.ValidateEmailRequest;
import com.xwebservices.ws.xwebemailvalidation.emailvalidation.v2.messages.ValidateEmailResponse;
/**
* SCA Java Component implementation using the mail verification web service
*/
public class Client implements Runnable {
/** Reference on the provided weather service */
@Reference
protected XWebEmailValidationInterface mailValidator;
/** Run method for the weather client component */
public void run() {
//mailValidator.validateEmail(messagePart)
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter mail to verify: ");
try {
String mail = input.readLine();
ValidateEmailRequest request = new ObjectFactory().createValidateEmailRequest();
request.setEmail(mail);
ValidateEmailResponse response = mailValidator.validateEmail(request);
System.out.println("The mail " + mail + " is " + response.getStatus());
} catch (IOException e) {
System.err.println("Can't read input data!");
e.printStackTrace();
}
}
}
<?xml version="1.0" encoding="ISO-8859-15"?>
<!-- OW2 FraSCAti Examples: Verify mail -->
<!-- Copyright (C) 2009 INRIA, USTL -->
<!-- -->
<!-- This library is free software; you can redistribute it and/or -->
<!-- modify it under the terms of the GNU Lesser General Public -->
<!-- License as published by the Free Software Foundation; either -->
<!-- version 2 of the License, or (at your option) any later version. -->
<!-- -->
<!-- This library is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -->
<!-- Lesser General Public License for more details. -->
<!-- -->
<!-- You should have received a copy of the GNU Lesser General Public -->
<!-- License along with this library; if not, write to the Free Software -->
<!-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
<!-- -->
<!-- Author: Nicolas Dolet -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="verifymail"
targetNamespace="http://frascati.ow2.org/verifymail">
<service name="r" promote="client/r">
<interface.java interface="java.lang.Runnable" />
</service>
<component name="client">
<implementation.java class="org.ow2.frascati.examples.verifymail.Client" />
<service name="r">
<interface.java interface="java.lang.Runnable" />
</service>
<reference name="mailValidator">
<interface.java interface="com.xwebservices.ws.xwebemailvalidation.emailvalidation.v2.XWebEmailValidationInterface" />
<binding.ws wsdlElement="http://ws.xwebservices.com/XWebEmailValidation/V2#wsdl.port(EmailValidation/EmailValidation)" />
</reference>
</component>
</composite>
<definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:ws-xwebservices-com:XWebEmailValidation:EmailValidation:v2" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:import0="urn:ws-xwebservices-com:XWebEmailValidation:EmailValidation:v2:Messages" targetNamespace="urn:ws-xwebservices-com:XWebEmailValidation:EmailValidation:v2" name="XWebEmailValidation" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema>
<xsd:import schemaLocation="XWebEmailValidation.xsd" namespace="urn:ws-xwebservices-com:XWebEmailValidation:EmailValidation:v2:Messages" />
</xsd:schema>
</types>
<message name="validateEmailIn">
<part name="messagePart" element="import0:ValidateEmailRequest" />
</message>
<message name="validateEmailOut">
<part name="messagePart" element="import0:ValidateEmailResponse" />
</message>
<portType name="XWebEmailValidationInterface">
<operation name="ValidateEmail">
<input message="tns:validateEmailIn" />
<output message="tns:validateEmailOut" />
</operation>
</portType>
<binding name="XWebEmailValidation" type="tns:XWebEmailValidationInterface">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<operation name="ValidateEmail">
<soap:operation soapAction="urn:ws-xwebservices-com:XWebEmailValidation:EmailValidation:v2:validateEmailIn" style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="EmailValidation">
<port name="EmailValidation" binding="tns:XWebEmailValidation">
<soap:address location="http://ws.xwebservices.com/XWebEmailValidation/V2/EmailValidation.asmx" />
</port>
</service>
</definitions>
<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema id="XWebEmailValidation" targetNamespace="urn:ws-xwebservices-com:XWebEmailValidation:EmailValidation:v2:Messages"
elementFormDefault="qualified" xmlns="urn:ws-xwebservices-com:XWebEmailValidation:EmailValidation:v2:Messages"
xmlns:mstns="urn:ws-xwebservices-com:XWebEmailValidation:EmailValidation:v2:Messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ValidateEmailRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Email" type="xsd:string" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ValidateEmailResponse">
<xsd:complexType>
<xsd:all>
<xsd:element name="Status">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="VALID" />
<xsd:enumeration value="NOT_VALID" />
<xsd:enumeration value="EMAIL_SERVER_UNAVAILABLE" />
<xsd:enumeration value="EMAIL_SERVER_NOT_FOUND" />
<xsd:enumeration value="SYSTEM_ERROR" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment