Resume Parse Solution(一)Sovren and Axis2 SOAP Client
发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
Resume Parse Solution(1)Sovren and Axis2 SOAP Client
Resume Parse Solution(1)Sovren and Axis2 SOAP Client
1. Commercial Solution
sovren
http://www.sovren.com/
Rchilli
http://rchilli.com/
HireAbility
http://www.hireability.com/
Daxtra
http://www.daxtra.com/
2. Open Source Solution
…todo...
3. Demo and Try SovRen
My lovely SOAP, I will use wsdl and SOAP again after 5 years...
Axis2
Install and Prepare Axis2
http://mirror.metrocast.net/apache//axis/axis2/java/core/1.6.3/axis2-1.6.3-bin.zip
unzip the file and find a nice place for that.
> wsdl2java.sh -help
Using AXIS2_HOME: /opt/axis2
Using JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
Usage: WSDL2Java [options] -uri <url or path> : A url or path to a WSDL
Here is the command to generate the codes
> wsdl2java.sh -uri http://services.resumeparsing.com/ParsingService.asmx?wsdl -S src/main/java/ -p com.sillycat.resumeparse.sovren.stub -t --noBuildXML -or
-uri URL of the wsdl file
-S source file location
-p customer package name
-t Generate the test Class (Not much use)
—noBuildXML No build the build.xml, because I am using maven
-or overwrite the file
Here is the dependencies in pom.xml
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.schema</groupId>
<artifactId>XmlSchema</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>org.apache.neethi</groupId>
<artifactId>neethi</artifactId>
<version>3.0.3</version>
</dependency>
Write the Implementation Class, ParsingServiceSovrenClient.java
package com.sillycat.resumeparse.sovren;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.rmi.RemoteException;
import java.util.zip.GZIPOutputStream;
import javax.activation.DataHandler;
import org.apache.axiom.attachments.ByteArrayDataSource;
import org.apache.axis2.AxisFault;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sillycat.resumeparse.ParsingServiceClient;
import com.sillycat.resumeparse.sovren.stub.ParsingServiceStub;
import com.sillycat.resumeparse.sovren.stub.ParsingServiceStub.ParseResume;
import com.sillycat.resumeparse.sovren.stub.ParsingServiceStub.ParseResumeRequest;
import com.sillycat.resumeparse.sovren.stub.ParsingServiceStub.ParseResumeResponse;
import com.sillycat.resumeparse.sovren.stub.ParsingServiceStub.ParseResumeResponseE;
public class ParsingServiceSovrenClient implements ParsingServiceClient {
protected final static Log log = LogFactory
.getLog(ParsingServiceSovrenClient.class);
private String accountId;
private String serviceKey;
private String filePath;
private String soapServer;
public void parseResume(String fileName) {
long read_file_start = System.currentTimeMillis();
byte[] bytes = null;
try {
bytes = getBytesFromFile(new File(filePath + fileName));
} catch (IOException e) {
log.error(e,e);
}
long read_file_end = System.currentTimeMillis();
// Optionally, compress the bytes to reduce network transfer time
long gzip_file_start = System.currentTimeMillis();
try {
bytes = gzip(bytes);
} catch (IOException e) {
log.error(e,e);
}
long gzip_file_end = System.currentTimeMillis();
ByteArrayDataSource rawData = new ByteArrayDataSource(bytes);
DataHandler fileData = new DataHandler(rawData);
// Get a client proxy for the web service
ParsingServiceStub stub = null;
try {
if(this.getSoapServer() != null && !this.getSoapServer().equals("")){
stub = new ParsingServiceStub(this.getSoapServer());
}else{
stub = new ParsingServiceStub();
}
} catch (AxisFault e) {
log.error(e,e);
} catch(Exception e){
log.error(e, e);
}
// Required parameters
ParseResumeRequest request = new ParseResumeRequest();
request.setAccountId(this.getAccountId());
request.setServiceKey(this.getServiceKey());
request.setFileBytes(fileData);
ParseResume resumeRequest = new ParseResume();
resumeRequest.setRequest(request);
long call_api_start = System.currentTimeMillis();
ParseResumeResponse response = null;
try {
ParseResumeResponseE result1 = stub.parseResume(resumeRequest);
if (result1 != null) {
response = result1.getParseResumeResult();
}
} catch (RemoteException e) {
log.error(e,e);
}
long call_api_end = System.currentTimeMillis();
log.info("Load the file to Memory, using "
+ (read_file_end - read_file_start) + " ms");
log.info("Zip the file, using " + (gzip_file_end - gzip_file_start)
+ " ms");
log.info("Call the API, using "
+ (call_api_end - call_api_start) + " ms");
if (response != null) {
log.debug("--------------------------------");
log.debug("Code=" + response.getCode());
log.debug("SubCode=" + response.getSubCode());
log.debug("Message=" + response.getMessage());
log.debug("TextCode=" + response.getTextCode());
log.debug("CreditsRemaining=" + response.getCreditsRemaining());
log.debug("--------------------------------");
log.debug(response.getXml());
log.debug("--------------------------------");
}
}
private byte[] getBytesFromFile(File file) throws IOException {
InputStream is = new FileInputStream(file);
try {
// Get the size of the file
long length = file.length();
if (length > Integer.MAX_VALUE) {
// File is too large
}
// Create the byte array to hold the data
byte[] bytes = new byte[(int) length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
offset += numRead;
}
// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException("Could not completely read file "
+ file.getName());
}
// Return the file content
return bytes;
} finally {
// Close the input stream
is.close();
}
}
private byte[] gzip(byte[] bytes) throws IOException {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(
bytes.length / 2);
try {
GZIPOutputStream zipStream = new GZIPOutputStream(byteStream);
try {
zipStream.write(bytes);
} finally {
zipStream.close();
}
return byteStream.toByteArray();
} finally {
byteStream.close();
}
}
}
Here is the Test Class, SovrenParsingServiceClientTest.java
package com.sillycat.resumeparse;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import com.sillycat.resumeparse.sovren.ParsingServiceSovrenClient;
public class SovrenParsingServiceClientTest extends BaseTest{
ParsingServiceClient parsingServiceClient;
@Before
public void setUp() {
parsingServiceClient = new ParsingServiceSovrenClient();
parsingServiceClient.setAccountId(“xxxxxxx");
parsingServiceClient.setServiceKey(“xxxxxxxx");
parsingServiceClient.setFilePath("/Users/carl/data/resume/");
}
@Test
public void dummy(){
Assert.assertTrue(true);
}
@Test
public void parseResume(){
parsingServiceClient.parseResume(“5-carl.pdf");
}
}
References:
http://resumeparsing.com/ResumeService.htm
http://resumeparsing.com/ParsingService.htm
Some SOAP Method
http://sillycat.iteye.com/blog/562769
http://sillycat.iteye.com/blog/1555080
http://sillycat.iteye.com/blog/978895
http://sillycat.iteye.com/blog/716791
http://sillycat.iteye.com/blog/706076
http://sillycat.iteye.com/blog/562769
http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jst.ws.cxf.doc.user%2Ftasks%2Fcreate_client.html
Three popular SOAP provider
http://projects.spring.io/spring-ws/
http://axis.apache.org/axis2/java/core/download.cgi
http://cxf.apache.org/download.html
Async SOAP Client
http://downloads.typesafe.com/rp/play-soap/PlaySoapClient.html
https://www.playframework.com/documentation/3.0.x/ScalaWS
https://github.com/vmencik/soap-async
JAX-WS WSDL
http://www.mkyong.com/webservices/jax-ws/jax-ws-wsimport-tool-example/
http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
2018 SOAP(1)Introduction and Build the Client/Server from WSDL
2018 SOAP(1)Introduction and Build the Client/Server...
-
(七) 构建dubbo分布式平台-maven构建ant-framework框架的pom.xml文件配置
上一篇我们介绍《构建dubbo分布式平台-maven构建...
-
Java xml与实体Bean的转换
1、pom.xml依赖包:
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<...
-
初识php soap 学习过程中的摘抄,便于后期翻阅
SOAP 简单对象访问协议,
webService三要素 , SOAP、WSDL(WebServicesDescriptionLa...
-
优秀的XML可视化在线编辑工具介绍
XML可视化在线编辑工具
——业内首创的在线可视化XML结构化数据编辑方法
Boxth Vi...
-
mybatis配置的Mapper.xml中参数有中文问题
mybatis配置的Mapper.xml中参数有中文问题,
某个查询的条件中需要传递中文字符串...
-
tomcat 配置多个路径 server.xml
<Context path="/helloApp1" docBase="helloApp1的绝对或相对路径" debug="0" reloadable=...
-
Idea的xml打开形式是file类型错误修改
今天早上创建一个xml文件的时候,下意识的下一步到了最后,然后发现自己以前...
-
android 屏幕适配1 ——dimens.xml的适配
1.如果是才开始做项目,已经有设计图:720*1280
1).默认values文件夹:1dp=1px
values/...
-
maven初使用遇到的一些问题-新建maven项目时pom.xml报的缺包错误
其实,也不是才接触maven,只是以前配置的时候...