我試過 Req.OptionalInputs.FieldLocatorOpeningPattern =「< <」; Req.OptionalInputs.FieldLocatorClosingPattern =「>>」;Can Field定位符可與CoSign Signature Soap API一起使用C#
但符號不會被pdf中提供的空間替換。您能否提供一個使用Soap API的代碼示例。
我試過 Req.OptionalInputs.FieldLocatorOpeningPattern =「< <」; Req.OptionalInputs.FieldLocatorClosingPattern =「>>」;Can Field定位符可與CoSign Signature Soap API一起使用C#
但符號不會被pdf中提供的空間替換。您能否提供一個使用Soap API的代碼示例。
請參閱下面的使用餘弦簽名SOAP API(又名SAPIWS)與餘弦簽名定位器的代碼示例:
public SAPISigFieldSettingsType[] getSigFieldLocatorsInPDF(
string FileName,
string UserName,
string Password)
{
//Create Request object contains signature parameters
RequestBaseType Req = new RequestBaseType();
Req.OptionalInputs = new RequestBaseTypeOptionalInputs();
//Here Operation Type is set: enum-field-locators
Req.OptionalInputs.SignatureType = SignatureTypeFieldLocators;
//Configure Create and Sign operation parameters:
Req.OptionalInputs.ClaimedIdentity = new ClaimedIdentity();
Req.OptionalInputs.ClaimedIdentity.Name = new NameIdentifierType();
Req.OptionalInputs.ClaimedIdentity.Name.Value = UserName; //User Name
Req.OptionalInputs.ClaimedIdentity.Name.NameQualifier = " "; //Domain (relevant for Active Directory environment only)
Req.OptionalInputs.ClaimedIdentity.SupportingInfo = new CoSignAuthDataType();
Req.OptionalInputs.ClaimedIdentity.SupportingInfo.LogonPassword = Password; //User Password
Req.OptionalInputs.FieldLocatorOpeningPattern = "<<";
Req.OptionalInputs.FieldLocatorClosingPattern = ">>";
//Set Session ID
Req.RequestID = Guid.NewGuid().ToString();
//Prepare the Data to be signed
DocumentType doc1 = new DocumentType();
DocumentTypeBase64Data b64data = new DocumentTypeBase64Data();
Req.InputDocuments = new RequestBaseTypeInputDocuments();
Req.InputDocuments.Items = new object[1];
b64data.MimeType = "application/pdf"; //Can also be: application/msword, image/tiff, pplication/octet-string
Req.OptionalInputs.ReturnPDFTailOnlySpecified = true;
Req.OptionalInputs.ReturnPDFTailOnly = false;
b64data.Value = ReadFile(FileName, true); //Read the file to the Bytes Array
doc1.Item = b64data;
Req.InputDocuments.Items[0] = doc1;
//Call sign service
ResponseBaseType Resp = null;
try
{
// Create the Web Service client object
DSS service = new DSS();
service.Url = "https://prime.cosigntrial.com:8080/sapiws/dss.asmx"; //This url is constant and shouldn't be changed
SignRequest sreq = new SignRequest();
sreq.InputDocuments = Req.InputDocuments;
sreq.OptionalInputs = Req.OptionalInputs;
//Perform Signature operation
Resp = service.DssSign(sreq);
if (Resp.Result.ResultMajor != Success)
{
MessageBox.Show("Error: " + Resp.Result.ResultMajor + " " +
Resp.Result.ResultMinor + " " +
Resp.Result.ResultMessage.Value, "Error");
return null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
if (ex is WebException)
{
WebException we = ex as WebException;
WebResponse webResponse = we.Response;
if (webResponse != null)
MessageBox.Show(we.Response.ToString(), "Web Response");
}
return null;
}
//Handle Reply
DssSignResult sResp = (DssSignResult) Resp;
return Resp.OptionalOutputs.SAPISeveralSigFieldSettings;
}
謝謝阿里和拉里!但我試過這段代碼,並且出現以下錯誤「無法驗證用戶名和密碼」。也檢查了我的用戶名和密碼的正確性。我使用的簽名類型操作是SignatureTypeFieldLocators =「http:// arx.com/SAPIWS/DSS/1.0/signature-field-sign」。 –
指向與您嘗試連接的設備不同的其他設備的服務URL。它現在應該正常工作,因爲它現在指向了CoSign試用設備。 –
感謝Almog.Its工作.... –
請詳細說明你的問題。 – Nilambar
我正在使用CoSign簽名SOAP API。我需要在我的pdf上的指定位置上簽名。CoSign簽名本地我可以看到有一個選項在動態位置上簽名(使用字段定位器)。我正在尋找相同的在CoSign簽名SOAP API中。 –