概览:
海海软件Media-DRM许可证服务提供接口您可以在您的网站中调用。通过调用Media-DRM许可证,可以与您的网站无缝集成应用海海软件Media-DRM。
整个流程非常简单:
一. 您在网站集成参数中设置登录验证Media-DRM许可证服务验证码和许可证验证URL。
二. 您建立一个新的Media-DRM登陆页面或者在您已有的页面中接受Media-DRM传递过来的3个参数 ProfileID,ClientInfo,RightsID。
三. 在您处理完成用户验证或者确认支付后,调用 getLicenseRemote函数获取许可证。
总之,您只需调用 getLicenseRemote函数,并提供几个参数,然后Media-DRM许可证服务将会给您返回许可证值。
Media-DRM许可证服务需要以下参数:
AdminEmail 是您登陆Media-DRM帐户的邮件地址。
WebServiceAuthStr 是登录验证Media-DRM许可证服务验证码。您可以在Media-DRM帐户信息->;网站集成参数中设置此验证码。
ProfileID 是许可证模版ID 或者编码器许可证模版ID. Media-DRM 提供此参数。
ClientInfo 客户端基本信息. Media-DRM 提供此参数。
RightsID 是您在Media-DRM帐户创建的权限ID. 您可以在Media-DRM帐户许可证权限列表中找到权限ID。
UserLoginName 是您用户数据库中的用户名或者是用户ID,UserLoginName必须是在您的数据库是唯一的。
UserFullName 是您用户数据库中的用户姓名。这个参数是选项。你可以留空,或者将它的值设置为N/A。
GroupID是您在Media-DRM帐户创建的用户组ID. 您可以在Media-DRM帐户用户组列表中找到用户组ID。
Message 是Media-DRM 许可证服务返回的许可证消息信息。
当您在代码中调用getLicenseRemote,并且提供正确的参数,它将给您返回许可证值。
下面是详细的步骤:
第一步:由于需要调用XML网络服务,在您的服务器或者开发测试环境中首先需要安装需要安装Apache Tomcat。
第二步: 创建一个DRM登录页面,命名为drmlogin.jsp
下面是drmlogin.jsp代码(以下代码引用了类库:org.apache.axis.client.Service,org.apache.axis.client.Call,javax.xml.namespace.QName"%>)
<%@ page import="org.apache.axis.client.Service,org.apache.axis.client.Call,javax.xml.namespace.QName,org.apache.log4j.Level"%>
<%
String AdminEmail=" 您登录Media-DRMd的账户 ";
String WebServiceAuthStr=" 您的Media-DRM账户中设置的许可证服务验证码 ";
String ProfileID = request.getParameter("profileid");
out.println(ProfileID);
String ClientInfo = request.getParameter("clientinfo");
out.println(ClientInfo);
String RightsID = request.getParameter("rightsid");
out.println(RightsID);
String UserLoginName = " 您用户数据库中的用户名 ";
String UserFullName = " 用户名全名 ";
String GroupID=" 您在Media-DRM帐户创建的用户组ID ";
//javax.xml.rpc.holders.StringHolder Message=new javax.xml.rpc.holders.StringHolder();
//Message="N/A";
String Message="";
String license = "0";
String IP=request.getRemoteAddr();
String namespace="http://tempuri.org/ASPNET.StarterKit.Commerce/HaihaisoftLicenseService";
try {
String endPoint="http://www.media-drm.net/haihaisoftlicenseservice.asmx?wsdl";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endPoint));
//call.setOperationName(new javax.xml.namespace.QName("http://tempuri.org/SDRM/HaihaisoftDRMService","getLicenseRemote"));
call.setOperationName(new javax.xml.namespace.QName("http://tempuri.org/ASPNET.StarterKit.Commerce/HaihaisoftLicenseService", "getLicenseRemote"));
call.addParameter(new QName(namespace,"AdminEmail"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(namespace,"WebServiceAuthStr"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(namespace,"ProfileID"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(namespace,"ClientInfo"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(namespace,"RightsID"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(namespace,"UserLoginName"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(namespace,"UserFullName"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(namespace,"GroupID"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(namespace,"Message"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.INOUT);
call.addParameter(new QName(namespace,"IP"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
//call.setSOAPActionURI("http://tempuri.org/SDRM/HaihaisoftDRMService/getLicense");
//call.setSOAPActionURI("http://tempuri.org/ASPNET.StarterKit.Commerce/HaihaisoftLicenseService/getLicenseRemot");
call.setSOAPActionURI("http://tempuri.org/ASPNET.StarterKit.Commerce/HaihaisoftLicenseService/getLicenseRemote");
/* license = (String)call.invoke(new Object[]{AdminEmail,WebServiceAuthStr,ProfileID,ClientInfo,RightsID,UserLoginName,UserFullName, GroupID,Message,IP}); */
Object[] param={new String(AdminEmail),new String(WebServiceAuthStr),new String(ProfileID),new String(ClientInfo),new String(RightsID),new String(UserLoginName),new String(UserFullName),new String(GroupID),new String(Message),new String(IP)};
license = (String)call.invoke(param);
out.println("AdminEmail is "+AdminEmail);
out.println("WebServiceAuthStr is "+WebServiceAuthStr);
out.println("ProfileID is "+ProfileID);
out.println("RightsID is "+RightsID);
out.println("UserLoginName is "+UserLoginName);
out.println("UserFullName is "+UserFullName);
out.println("GroupID is "+GroupID);
out.println("IP is "+IP);
out.println("==========="+Message);
out.println("==========="+license);
} catch (Exception e) {
e.printStackTrace();
}
if(license == null || license.equals("0")){
%>
license
<%
} else {
session.setAttribute("license", ""+license);
session.setAttribute("message", Message.value);
response.sendRedirect("licstore.jsp");
return ; out.println("===");
}
%>
代码详解:在上面的代码中,我们主要工作是通过request.getParameter获取了profileid,clientinfo,rightsid参数。这3个参数是通过播放器打开加密后的文件时,会用form Post的形式提供参数,profileid,clientinfo,rightsid.
在提供了所有正确对应的参数后,通过调用license = (String)call.invoke(param);获取许可证license。
当用获得许可证license不是空的时候,我们就可以把license和返回的message消息用session存储。
session.setAttribute("license", ""+license);
session.setAttribute("message", Message.value);
并跳转到licstore.jsp将许可证和Message显示出来。
下面是licstore.jsp的代码:
<%@ page contentType="text/html; charset=gb2312"%>
<html>
<head>
<title>licstore</title>
<Script Language="JavaScript">function storeLic(){netobj.StoreLicense("<%= session.getAttribute("license") %>");
</Script>
</head>
<body bgcolor="#e8e8d8" class="content" onLoad="storeLic()">
<object id="netobj" CLASSID="clsid:A9FC132B-096D-460B-B7D5-1DB0FAE0C062" width="0" height="0" VIEWASTEXT>
</object>
<%= session.getAttribute("Message") %>"
</body>
</html>
第三步: 运行 drmlogin.jsp 页. 因为在运行drmlogin.jsp 页之前您需要Media-DRM为您提供ProfileID, ClientInfo, RightsID参数,所以你需要打开你的加密后的文件来运行drmlogin.jsp。要让打开你的加密后的文件来运行drmlogin.jsp,您需要在DRM-X帐户->网站集成参数中设置许可证URL。 如果在运行时返回了Message和License 说明运行成功,否则检查所有参数,重新尝试打开你的加密后的文件来运行drmlogin.jsp。