PDA

View Full Version : automating the registration and activation process



copkillaNoOne
07-06-2009, 09:22 AM
Hi, I would appreciate and would be very grateful, if somebody could help me with this outstanding issue...

Is this possible ?

I would like to create, respectively activate my product by an automated process, after the customer has installed my product, he should edit some infos in a form or dialog, send a fulfillmentID or Serial-Number to the server and receive a license file by mail (or is it possible to create one at client side directly ?).

without anyone touches the web-platform for generating any xml or license files manually...

I´ve seen the example in C:\FlexNet\Publisher\examples\fulfill could I use a similar code to implement my needs ? Or is there any better way (other than Java-Web-Services) ... ?

Thanks a lot in advance,

CopkillaNoOne...

RobertDickau
07-06-2009, 06:46 PM
What type of licensing are you using, license file-based or trusted storage-based? And are you using FLEXnet Operations?

If you're using trusted storage and using FLEXnet Operations, your activation utility should be able to speak directly to FNO to fulfill licenses. For license file-based licensing, there's not a built-in fulfillment, but you could perhaps set up the FNO customer portal for creating license files...

copkillaNoOne
07-07-2009, 02:04 AM
What type of licensing are you using, license file-based or trusted storage-based? And are you using FLEXnet Operations?

If you're using trusted storage and using FLEXnet Operations, your activation utility should be able to speak directly to FNO to fulfill licenses. For license file-based licensing, there's not a built-in fulfillment, but you could perhaps set up the FNO customer portal for creating license files...

First, Hi Robert and thank you for the fast reply.
Yes I´m using operations and have set up a customer portal... we have some problems with the customers, that they don´t want to have any services installed on their machines, so we have to use license files.

The problem is that we have to automate the process, and the customer should not login to the customer portal, but he should receive a license file via email or maybe created locally by our client-application.

I´ve seen the sample in \Publisher\examples\fulfill some 'c' code, where the license information get read into a buffer and printed on to the standard output device. Isn´t it possible to do so with a license ? and writing to a file directly after getting response from FNO ?

Thanks for your patience... :o

P.S.: Could we use the web-services to accomplish our needs ?

RobertDickau
07-07-2009, 10:07 AM
The FNO web services do support generating and e-mailing license files. Please search the web services guide for "generateLicense" and "emailLicense" for more information, and see the code samples in the subdirectory site/samples/webservices/licenses...

copkillaNoOne
07-07-2009, 10:10 AM
The FNO web services do support generating and e-mailing license files. Please search the web services guide for "generateLicense" and "emailLicense" for more information, and see the code samples in the subdirectory site/samples/webservices/licenses...

Thanks for reply... :) is Java necessary or can I use .NET also... (because of
probable compatibility issues and not having all the methods available)...

Thanks and will look into suggested topic.

RobertDickau
07-07-2009, 10:41 AM
The samples that ship with FNO are set up to use Axis + Java, but it's not a requirement. The web services guide has some general information about creating other types of clients, including the "ClientSecurityCredentials Class Source" appendix that mentions the need for Basic HTTP authentication in the client. (I've had some luck using C# and VB.NET for FNO web service clients, as it's a fairly straightforward translation from Java.)

copkillaNoOne
07-07-2009, 02:11 PM
The samples that ship with FNO are set up to use Axis + Java, but it's not a requirement. The web services guide has some general information about creating other types of clients, including the "ClientSecurityCredentials Class Source" appendix that mentions the need for Basic HTTP authentication in the client. (I've had some luck using C# and VB.NET for FNO web service clients, as it's a fairly straightforward translation from Java.)

ok, that would make my life a bit asier... :rolleyes: ... are there any samples for usage of c# or vb.net ? does anybody have some snippets ?

I appreaciate any help, and if I could, i would spend a beer or two via the net !!

Thanks for the help.
cheers...

RobertDickau
07-08-2009, 02:58 PM
I've had luck with the following; most of the tricky part is putting the "Basic" HTTP authentication in there, which Java + Axis seems to handle automatically.


Start the Operations server, and verify that http://host:port/flexnet/services reflects that the service is running.


Log in to Operations, open the Administer Operations view, select System Configuration, Validators category; clear the check box next to Web Service Request Validation Enabled.


In Visual Studio (I last tried with VS 2005), create a new C# console project (below called ConsoleApplication1).


In the Solution Explorer, right-click the project icon and select Add Web Reference.


In the Add Web Reference page, enter http://host:port/flexnet/services and click Go. Click the (wsdl) link next to the service you want to use (for this example, ProductPackagingService). You should see a list of methods in the "ProductPackagingService" Description section.


Change the Web reference name field to (for example) prodpkgsvc, and click Add Reference. The Solution Explorer view should have a new prodpkgsvc icon in the Web References folder.


Double-click the prodpkgsvc icon, which opens the Object Browser.


In the Object Browser, expand ConsoleApplication1.prodpkgsvc, and double-click one of the items in the tree. This should open the proxy class source file Reference.cs.


Near the top of Reference.cs, find the line that begins:

public partial class ProductPackagingService : ...

and insert the following function:


protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request;
request = (HttpWebRequest)base.GetWebRequest(uri);

if (PreAuthenticate)
{
NetworkCredential networkCredentials =
Credentials.GetCredential(uri, "Basic");
if (networkCredentials != null)
{
byte[] credentialBuffer =
new
System.Text.UTF8Encoding( ).GetBytes(
networkCredentials.UserName + ":" +
networkCredentials.Password);

request.Headers["Authorization"] =
"Basic " +
Convert.ToBase64String(credentialBuffer);
}
else
{
throw new ApplicationException(
"No network credentials");
}
}
return request;
}

It might also be necessary to add this to the top of the file:

using System.Net;

This overridden function specifies that requests are to use "Basic" HTTP authentication, adding a new "Authorization" header with credentials of the form "Basic " plus the base-64-encoded "Name:Password" string.


In the client code (Program.cs), you create web service requests and retrieve responses similar to the technique used in the Java examples. For example, the following code creates a simple report of the products currently defined in the Operations database:


using System;
using System.Collections.Generic;
using System.Text;

using ConsoleApplication1.prodpacksvc;
using System.Net;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ProductPackagingService pps = new ProductPackagingService( );

NetworkCredential netCredential = new NetworkCredential("admin", "admin");
Uri uri = new Uri(pps.Url);

ICredentials credentials = netCredential.GetCredential(uri, "Basic");

pps.Credentials = credentials;
pps.PreAuthenticate = true;

getProductCountRequestType pcreq = new getProductCountRequestType( );

productQueryParametersType pqp = new productQueryParametersType( );
pcreq.queryParams = pqp;

getProductCountResponseType pcresp = pps.getProductCount(pcreq);

Console.Out.WriteLine(
"Product count: " + pcresp.responseData.count + "\n");

if (pcresp.statusInfo.status == StatusType.SUCCESS)
{
getProductsQueryRequestType pqreq =
new getProductsQueryRequestType( );

pqreq.queryParams = pqp;

pqreq.batchSize = "50";
pqreq.pageNumber = "1";

getProductsQueryResponseType pqresp = pps.getProductsQuery(pqreq);

Console.Out.WriteLine("\nProduct report:");

productQueryDataType[] pqrespdata = pqresp.responseData;

if (pqrespdata != null)
{
foreach (productQueryDataType pqd in pqrespdata)
{
Console.Out.WriteLine(
pqd.productName +
" (version " + pqd.version + ", " +
pqd.state + " state)");
}
}
}
else
{
Console.Out.WriteLine("Error: " + pcresp.statusInfo.reason);
}
}
}
}

copkillaNoOne
07-09-2009, 04:00 AM
I've had luck with the following; most of the tricky part is putting the "Basic" HTTP authentication in there, which Java + Axis seems to handle automatically.


Start the Operations server, and verify that http://host:port/flexnet/services reflects that the service is running.


Log in to Operations, open the Administer Operations view, select System Configuration, Validators category; clear the check box next to Web Service Request Validation Enabled.


In Visual Studio (I last tried with VS 2005), create a new C# console project (below called ConsoleApplication1).


In the Solution Explorer, right-click the project icon and select Add Web Reference.


In the Add Web Reference page, enter http://host:port/flexnet/services and click Go. Click the (wsdl) link next to the service you want to use (for this example, ProductPackagingService). You should see a list of methods in the "ProductPackagingService" Description section.


Change the Web reference name field to (for example) prodpkgsvc, and click Add Reference. The Solution Explorer view should have a new prodpkgsvc icon in the Web References folder.


Double-click the prodpkgsvc icon, which opens the Object Browser.


In the Object Browser, expand ConsoleApplication1.prodpkgsvc, and double-click one of the items in the tree. This should open the proxy class source file Reference.cs.


Near the top of Reference.cs, find the line that begins:

public partial class ProductPackagingService : ...

and insert the following function:


protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request;
request = (HttpWebRequest)base.GetWebRequest(uri);

if (PreAuthenticate)
{
NetworkCredential networkCredentials =
Credentials.GetCredential(uri, "Basic");
if (networkCredentials != null)
{
byte[] credentialBuffer =
new
System.Text.UTF8Encoding( ).GetBytes(
networkCredentials.UserName + ":" +
networkCredentials.Password);

request.Headers["Authorization"] =
"Basic " +
Convert.ToBase64String(credentialBuffer);
}
else
{
throw new ApplicationException(
"No network credentials");
}
}
return request;
}

It might also be necessary to add this to the top of the file:

using System.Net;

This overridden function specifies that requests are to use "Basic" HTTP authentication, adding a new "Authorization" header with credentials of the form "Basic " plus the base-64-encoded "Name:Password" string.


In the client code (Program.cs), you create web service requests and retrieve responses similar to the technique used in the Java examples. For example, the following code creates a simple report of the products currently defined in the Operations database:


using System;
using System.Collections.Generic;
using System.Text;

using ConsoleApplication1.prodpacksvc;
using System.Net;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ProductPackagingService pps = new ProductPackagingService( );

NetworkCredential netCredential = new NetworkCredential("admin", "admin");
Uri uri = new Uri(pps.Url);

ICredentials credentials = netCredential.GetCredential(uri, "Basic");

pps.Credentials = credentials;
pps.PreAuthenticate = true;

getProductCountRequestType pcreq = new getProductCountRequestType( );

productQueryParametersType pqp = new productQueryParametersType( );
pcreq.queryParams = pqp;

getProductCountResponseType pcresp = pps.getProductCount(pcreq);

Console.Out.WriteLine(
"Product count: " + pcresp.responseData.count + "\n");

if (pcresp.statusInfo.status == StatusType.SUCCESS)
{
getProductsQueryRequestType pqreq =
new getProductsQueryRequestType( );

pqreq.queryParams = pqp;

pqreq.batchSize = "50";
pqreq.pageNumber = "1";

getProductsQueryResponseType pqresp = pps.getProductsQuery(pqreq);

Console.Out.WriteLine("\nProduct report:");

productQueryDataType[] pqrespdata = pqresp.responseData;

if (pqrespdata != null)
{
foreach (productQueryDataType pqd in pqrespdata)
{
Console.Out.WriteLine(
pqd.productName +
" (version " + pqd.version + ", " +
pqd.state + " state)");
}
}
}
else
{
Console.Out.WriteLine("Error: " + pcresp.statusInfo.reason);
}
}
}
}



Hi Robert,
thank you very much for the excellent description !!!!!

I´ve had a lot of trouble with that authentication stuff, and I found a solution,
that works similar to yours, but without having to change the Reference.cs:
(only if you have interest for it)



class LicenseProxyWrapper : LicenseProxy.LicenseService
{
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri);
NetworkCredential credentials = Credentials as NetworkCredential;
if(credentials != null)
{
string authInfo =
(
(credentials.Domain != null) &&
(credentials.Domain.Length > 0) ? credentials.Domain + @"\" : string.Empty
) + credentials.UserName + ":" + credentials.Password;

authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
webRequest.Headers["Authorization"] = "Basic " + authInfo;
}

return webRequest;
}
}



I was simply subclassing the VS2005 generated proxy, and I could create
instances of the wrapper of the proxy class for using the methods. Of
course setting the Network credentials as you did... etc.
Anyway, the code works fine, and the Java samples are pretty self-explanating...

But there is one (hopefully last) thing...
I tried to use the createlicensetest.java sample and implement it in c#,
but the line:
CreateFulfillmentRequestType cpRequest = new CreateFulfillmentRequestType();

is making me headaches, the request type seems not to exist in the LicenseService ... ?? Is the usage different od is the class named differently ?

Am I missing something?

Thanks again...

RobertDickau
07-09-2009, 06:44 PM
Hmmm... The method names/capitalization are sometimes different in C# from Java, as you see in the sample I pasted. Does it work if you create the project from the WSDL files in the public-schema directory (as described in the web services guide) instead?

copkillaNoOne
07-10-2009, 03:39 AM
Hmmm... The method names/capitalization are sometimes different in C# from Java, as you see in the sample I pasted. Does it work if you create the project from the WSDL files in the public-schema directory (as described in the web services guide) instead?

Yes, I´ve tried that also, but there is no CreateFulFillmentRequest class appearing ... ? but in the documentation it is described as available.

I really have no ideas anymore... :( ...

Thanks a lot

RobertDickau
07-10-2009, 10:09 AM
Looking at it a bit more, it seems the createLicense method just takes the createFulfillmentDataType array directly as an argument, instead of using the createFulfillmentRequestType type. (Which makes sense, since createFulfillmentRequestType has only a single "fulfillment" member of type createFulfillmentDataType[].) Perhaps passing the array directly?

copkillaNoOne
07-10-2009, 10:23 AM
Looking at it a bit more, it seems the createLicense method just takes the createFulfillmentDataType array directly as an argument, instead of using the createFulfillmentRequestType type. (Which makes sense, since createFulfillmentRequestType has only a single "fulfillment" member of type createFulfillmentDataType[].) Perhaps passing the array directly?

Ok, I´ll try that. Thanks and have a nice weekend...

copkillaNoOne
07-13-2009, 04:31 AM
Ok, I´ll try that. Thanks and have a nice weekend...

ok, have tried it and it compiled without errors, but it doesn´t seem to work, mybe someone take a look and maybe see´s something I don´t :confused:




public void CreateLicense()
{
try
{
LicenseService lsv = new LicenseService();
NetworkCredential netCredential = new NetworkCredential("admin", "admin");

Uri uri = new Uri(lsv.Url);
ICredentials credentials = netCredential.GetCredential(uri, "Basic");
lsv.Credentials = credentials;
lsv.PreAuthenticate = true;

createFulfillmentDataType fmtData = new createFulfillmentDataType();

string activationId = _user._activationId;
fmtData.activationId = activationId;
fmtData.shipToAddress = _user._clientAddr;
fmtData.shipToEmail = _user._email;
fmtData.fulfillCount = "1";
fmtData.startDate = DateTime.Now;
fmtData.overDraftCount = "0";

// set the serverids if the model requires them
ServerIDsType servers = new ServerIDsType();
servers.server1 = "INTERNET=69.0.9.1";
fmtData.serverIds = servers;
// set the mode ids if the model requires them
//LicenseProxy licenseModelIdentifierType /*LicNodeIDsType*/ nodes = new LicenseProxy.licenseModelIdentifierType(); /*NodeIDsType()*/
//nodes.setNodeId = (new String[]{"abc123", "ccc333" , "dda122"});
fmtData.nodeIds = new String[] { "abc123", "ccc333", "dda122" } /*nodes*/;

attributeDescriptorType[] attrArray = new attributeDescriptorType[1];
attributeDescriptorType vsAttribute = new attributeDescriptorType();

vsAttribute.attributeName = "VENDOR_STRING";
vsAttribute.stringValue = "myvendorstring";
attrArray[0] = vsAttribute;

fmtData.licenseModelAttributes = attrArray;

createFulfillmentDataType[] fmtArray = new createFulfillmentDataType[1];
fmtArray[0] = fmtData;

createFulfillmentResponseType response = lsv.createLicense(fmtArray);

if(response.statusInfo.status.ToString().Equals(StatusType.SUCCESS.ToString()))
{
Console.Out.WriteLine("license created successfully ");
createdFulfillmentDataListType cpdlType = response.responseData;
createdFulfillmentDataType[] createdArray = cpdlType.createdFulfillment;

for(int i = 0; createdArray != null && i < createdArray.Length; i++)
{
Console.Out.WriteLine
(
"Record : " + (i + 1) + " , created License " +
createdArray[i].licenseText
);
}
}
else
{
Console.Out.WriteLine("license creation failed");
Console.Out.WriteLine
(
"Reason for Failure -> " +
response.statusInfo.reason
);
}
}
catch(Exception e)
{
Console.Out.WriteLine(e.StackTrace);
}
}





It says that 'Failure -> All input data in the request failed' And the license creation has failed!
error code -> 9999:null ??? What does that mean ?


Thanks in advance,
CkNoE

RobertDickau
07-13-2009, 09:50 AM
If you look in the FNO application log, is there any more information about what failed in the request?

copkillaNoOne
07-14-2009, 04:59 AM
If you look in the FNO application log, is there any more information about what failed in the request?

Hi, it says:

2009-07-14 11:39:25,889 ERROR [ops.ws] [http-0.0.0.0-8888-2] create license web service failed:The attribute name VENDOR_STRING is not valid [Incident# 3658-894R]
[Incident# 3658-894R] com.macrovision.flexnet.operations.exceptions.runtime.InvalidAttributeException: The attribute name VENDOR_STRING is not valid [Incident# 3658-894R]
but, I have inserted the right vendor inside !?!? :(


and I tried another sample (CreateLicenseOnCustomHost.java), where the vendorstring is not necessary and it says:
2009-07-14 11:50:02,686 ERROR [ops.ws] [http-0.0.0.0-8888-2] create license web service failed:null java.lang.NullPointerException


thanks
CkNoE

copkillaNoOne
07-14-2009, 08:47 AM
Hi, it says:

2009-07-14 11:39:25,889 ERROR [ops.ws] [http-0.0.0.0-8888-2] create license web service failed:The attribute name VENDOR_STRING is not valid [Incident# 3658-894R]
[Incident# 3658-894R] com.macrovision.flexnet.operations.exceptions.runtime.InvalidAttributeException: The attribute name VENDOR_STRING is not valid [Incident# 3658-894R]
but, I have inserted the right vendor inside !?!? :(


and I tried another sample (CreateLicenseOnCustomHost.java), where the vendorstring is not necessary and it says:
2009-07-14 11:50:02,686 ERROR [ops.ws] [http-0.0.0.0-8888-2] create license web service failed:null java.lang.NullPointerException


thanks
CkNoE


Ok, short update, I removed the errors above, they were caused due missing
attribute settings like "VENDOR=" and "VENDOR_DEFINED=" etc. now the
attribute settings are ok, but when trying to execute the generation I get
the following:

at java.lang.Thread.run(Thread.java:595)
Caused by: [Incident# 7514-9931] com.macrovision.flexnet.operations.exceptions.LicenseGeneratorException: License generator error: VCG exit value: 39 [Incident# 7514-9931]
at com.macrovision.flexnet.operations.services.VcgProcessPool$VcgProcess.getErrorException(VcgProcessPool.java:349)
at com.macrovision.flexnet.operations.services.VcgProcessPool$VcgProcess.grabOutput(VcgProcessPool.java:236)
at com.macrovision.flexnet.operations.services.VcgProcessPool$VcgProcess.<init>(VcgProcessPool.java:154)

cheers.

RobertDickau
07-14-2009, 12:35 PM
From memory I don't know the cause of that VCG error code. What if you try a product with the simplest possible license model (probably node-locked uncounted, not using NOTICE, VENDOR_STRING, etc.), and code with fewest attributes set...?

If you set FNO to the debug level of logging, you should be able to see the XML coming in from the web services, too, which might help.

copkillaNoOne
07-15-2009, 02:04 AM
From memory I don't know the cause of that VCG error code. What if you try a product with the simplest possible license model (probably node-locked uncounted, not using NOTICE, VENDOR_STRING, etc.), and code with fewest attributes set...?

If you set FNO to the debug level of logging, you should be able to see the XML coming in from the web services, too, which might help.

Ok, let´s try !

copkillaNoOne
07-16-2009, 07:04 AM
Ok, let&#180;s try !

NOPE, stays the same, I also checked the configuration but have no clue what it could be.

Maybe somone knows what the error code 39 means... ??

There are no special configuration steps taken, all default values are set besides the vendor daemon and ID_STRING=TRUSTED...

Thanks.

P.S.: 'If you set FNO to the debug level of logging,...' <- how to do that ?

RobertDickau
07-16-2009, 09:28 AM
The ID_STRING=TRUSTED suggests this is an activatable license model, which involves an activation utility talking directly to FNO. Perhaps try a license file-based license model?

For setting the log level, please go to Administer Operations > System Configuration; it should be in the first set of configuration settings.

copkillaNoOne
07-23-2009, 04:49 AM
The ID_STRING=TRUSTED suggests this is an activatable license model, which involves an activation utility talking directly to FNO. Perhaps try a license file-based license model?

For setting the log level, please go to Administer Operations > System Configuration; it should be in the first set of configuration settings.

Found the BUG!!! Everything works fine now !
It was something due to my vcg.exe... after downloading the 12.0 version
and re-building the vcg new, everything works perfect, with any license-model I create.


Thanks for Supporting me Mr. Dickau, thanks a lot !!!

regards,

CopKillaNoOne.

P.S.: If someone needs some snippets or samples, I´ll be glad to share...