On an xpage I run the following code:
function setPersonInfoCommon(x) {
//print("test printing to console value: " + x)
var serv = getPreferenceField("tx_server");
//e.g. "Development1";
var dbname = getPreferenceField("tx_loc_personal_common");
//e.g. "CustomerX\\Personnel.nsf"
var db:NotesDatabase = session.getDatabase(serv,dbname);
if (db == null) {
requestScope.status = "Database not found.";
return;
}
var vw:NotesView = db.getView("LookUpUsersUNID");
if (vw == null) {
requestScope.status = "View not found.";
return;
}
var doc:NotesDocument = vw.getDocumentByKey(x);
if (doc == null) {
requestScope.status = "Document not found.";
return;
}
else{
requestScope.status = "Document created:" + getCreated();
}
}
This freezes my XPage and in the log I see the following notation:
2014-08-19 12:46:11 HTTP JVM: com.ibm.xsp.webapp.FacesServlet$ExtendedServletException: com.ibm.xsp.FacesExceptionEx: java.io.NotSerializableException: lotus.domino.local.DateTime
2014-08-19 12:46:11 HTTP JVM: CLFAD0134E: Exception processing XPage request. For more detailed information, please consult error-log-0.xml located in E:/Domino/data/domino/workspace/logs
The XPage resides in a different NSF than the one I perform the getDocumentByKey method in. However I do not get any indication that the database (db) or view (vw) can not be found. If I check it by outputting the filepath or something I get the correct values returned.
I tested to run the code from within the NSF I perform the getDocumentByKey method and then the code runs just fine.
What can be the cause?
I am logged in via the web and have the proper rights.
Please always look at those more detailed logs in the location specified before posting a question. Those messages give much more information which will help identify the code causing the problem and usually a more detailed explanation.
In this particular case, the message on the console logs includes "java.io.NotSerializableException: lotus.domino.local.DateTime". Assuming this is relating to the line requestScope.status = "Document created:" + getCreated(); (the detailed logs will confirm) and that getCreated() is actually doc.getCreated(), that returns a NotesDateTime object.
NotesDateTime objects and any other Domino objects cannot be put in any scoped variable (there are various blogs explaining that Domino objects are not serializable).
If you want to put a date/time in a scope, you can get the Java date equivalent using NotesDateTime.toJavaDate(), so doc.getCreated().toJavaDate().
Related
I have created a webmethod in a C# webservice that listens for Docusign to call when an Envelope status changes:
[WebMethod]
public void DocuSignConnectUpdate(DocuSignEnvelopeInformation DocuSignEnvelopeInformation)
{
//Check if null
if (DocuSignEnvelopeInformation == null)
{
File.WriteAllText("C:\\websites\\DataAPI\\datalog.txt", "Data: " + "Data is null");
}
else
{
string envelopeId = "";
try
{
//Write a line in a file
File.WriteAllText("C:\\websites\\DataAPI\\datalog.txt", "Data: " + DocuSignEnvelopeInformation.ToString());
//Get some data out
envelopeId = DocuSignEnvelopeInformation.EnvelopeStatus.EnvelopeID;
//Write Data to a file
File.WriteAllText("C:\\websites\\DataAPI\\innerdatalog.txt", "Data: " + DocuSignEnvelopeInformation.ToString());
}
catch (Exception ex)
{
// could not serialize
File.WriteAllText("C:\\websites\\DataAPI\\errorlog.txt", "Exception: " + ex.Message);
throw new SoapException(ex.Message, SoapException.ClientFaultCode);
}
}
The issue I am having is that DocuSignEnvelopeInformation argument is not being set when called, so the code keeps terminating at the if==null statement. When I run the envelope data to the API using SoapUI everything works correctly. Any ideas what I'm missing would be appreciated.
EDIT: I wanted to Add the Interface here too since I forgot it originally
[ServiceContract(ConfigurationName = "IOperations", Namespace = "https://www.docusign.net/API/3.0")]
public interface IOperations
{
[OperationContract(Action = "DocuSignConnectListener/Operations/DocuSignConnectUpdate")]
[XmlSerializerFormat]
string DocuSignConnectUpdate(DocuSignEnvelopeInformation DocuSignEnvelopeInformation);
}
When a DocuSign webhook is set to use SOAP mode, the notification is sent as a SOAP request to your server (your listener).
If SOAP mode is off, then the notification is sent as a regular POST request with an XML body.
In your question, you say that
When I run the envelope data to the API using SoapUI everything works correctly
So it sounds like everything is worked as designed.
Ok I finally figured this out, turns out it just wasn't pretty enough so I added a decoration specifically:
[SoapDocumentMethod("http://tempuri.org/DocuSignConnectUpdate",
RequestNamespace = "http://tempuri.org",
ResponseNamespace = "http://tempuri.org",
Use = System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
on the method and now everything works like its supposed too. Now that I look at it, it makes a lot more sense.
The code below is a some test code that I have in an action button on an XPage. I need to get a handle on the current database with FullAccess in the code WFSUtils.sysOut just formats a printed message to the server console. Periodically the error message in the catch returns
2015-01-09 12:49:11 PM HTTP JVM: WFS ~~~ Error in Update Demo 'sessionAsSignerWithFullAccess' not found
I am the signer of the XPage and the database is signed by the server ID. Sometimes it runs through just fine other time it fails with the message above. If I shut everything down then restart it will generally run but then start failing. It is very random and unpredictable.
debug = true;
try{
if (debug) WFSUtils.sysOut("Starting YYY New SetupDemo");
var serverName = database.getServer();
var repID = database.getReplicaID();
thisDB = sessionAsSignerWithFullAccess.getDatabase("","");
thisDB.openByReplicaID(serverName,repID);
if (debug) WFSUtils.sysOut( "SetupDemo Success" + thisDB.getTitle());
}catch(e){
WFSUtils.sysOut("Error " + e.toString())
}finally{
try{
WFSUtils.recycleObjects([]);
if (debug) WFSUtils.sysOut("SetupDemo Recycle Success");
}catch(e){
if (debug) WFSUtils.sysOut("SetupDemo recycle Failed");
}
}
For one reason or another, it's important that all XPage elements be signed by the same ID when running. When they're not, sessionAsSigner and sessionAsSignerWithFullAccess get erratic as you describe - that may be the cause.
I realize this might come across as a very basic question, but I just downloaded Xamarin three days ago, and I've been stuck on the same issue for two days without finding a solution.
Here is what I am trying to do:
Get user input, call API, parse JSON and pass data to another controller, and change views.
Here is what I have been able to do so far: I get the user input, I call the API, I parse the response back, write the token to a file, and I want to pass the remaining data to the second controller.
This is the code I am trying:
var verifyCode = Storyboard.InstantiateViewController("verify") as VerifyCodeController;
if (verifyCode != null)
{
this.NavigationController.PushViewController(verifyCode, true);
}
My storyboard setup:
Navigation controller -> routesTo -> FirstController
I have another UI Controller View set up with the following properties set:
storyboardid: verify
restorationid: verify
and I am trying to push that controller view onto the navigation controller.
Right now this line is erroring out:
var verifyCode = Storyboard.InstantiateViewController("verify") as VerifyCodeController;
giving me this error, which I don't know what it means: Could not find an existing managed instance for this object, nor was it possible to create a new managed instance.
Am I way off in my approach?
p.s: I cannot use the ctrl drag thing like the tutorial suggests because I have an asynchronous call. And I cannot under no circumstances make it synchronous. So all the page transition has to be manual.
EDIT
to anyone requesting more code or more info:
partial void registerButton_TouchUpInside (UIButton sender)
{
phone = registrationNumber.Text;
string url = url;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create (url);
request.Method = "GET";
Console.WriteLine("Getting response...");
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
if (response.StatusCode != HttpStatusCode.OK)
{
Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
}
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string content = reader.ReadToEnd();
if (string.IsNullOrWhiteSpace(content))
{
//Console.WriteLine(text);
Console.Out.WriteLine("Response contained empty body...");
}
else
{
var json = JObject.Parse (content);
var token = json["token"];
var regCode = json["regCode"];
var aURL = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
var filename = Path.Combine (aURL, "app.json");
File.WriteAllText(filename, "{token: '"+token+"'}");
// transition to main view. THIS IS WHERE EVERYTHING GETS MESSED UP
var verifyCode = Storyboard.InstantiateViewController("verify") as VerifyCodeController;
if (verifyCode != null)
{
this.NavigationController.PushViewController(verifyCode, true);
}
}
}
}
}
Here is all the info for every view in my storyboard:
1- Navigation controller:
- App starts there
- The root is the register pager, which is the page we are currently working on.
2- The register view.
- The root page
- class RegisterController
- No storyboard id
- No restoration id
3- The validate view
- Not connected to the navigation controller initially, but I want it to be connected eventually. Do I have to connect it either way? Through a segue?
- class VerifyCodeController
- storyboard id : verify
- restoration id : verify
If you guys need more information I'm willing to post more. I just think I posted everything relevant.
This is my first time ever with Sharepoint. Here is the scenario
I have a stand alone web application
I also have a stand alone sharepoint server.
Both are on different servers.
I need to upload a file from web application to sharepoint
I found 2 methods online,
Using the webservice provided by Sharepoint (CopyIntoItems)
Using jQuery library of Sharepoint webservice
After searching the web, I think the jQuery part will not work (you can correct me).
I am looking for a method that takes username/password and uploads a pdf file to Sharepoint server. The following is my C# code that tries to upload but ends up in error
public bool UploadFile(string file, string destination)
{
bool success = false;
CopySoapClient client = new CopySoapClient();
if (client.ClientCredentials != null)
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
try
{
client.Open();
string filename = Path.GetFileName(file);
string destinationUrl = destination + filename;
string[] destinationUrls = { destinationUrl };
FieldInformation i1 = new FieldInformation { DisplayName = "Title", InternalName = "Title", Type = FieldType.Text, Value = filename };
FieldInformation[] info = { i1 };
CopyResult[] result;
byte[] data = File.ReadAllBytes(file);
//uint ret = client.CopyIntoItems(filename, destinationUrls, info, data, out result);
uint ret = client.CopyIntoItems(file, destinationUrls, info, data, out result);
if (result != null && result.Length > 0 && result[0].ErrorCode == 0)
success = true;
}
finally
{
if (client.State == System.ServiceModel.CommunicationState.Faulted)
client.Abort();
if (client.State != System.ServiceModel.CommunicationState.Closed)
client.Close();
}
return success;
}
I am calling the above function like this
UploadFile(#"C:\temp\uploadFile.txt", "http://spf-03:300/demo/Dokumente").ToString();
Error that i get:
Error Code: Destination Invalid
Error Message: The service method 'Copy' must be called on the same domain that contains the target URL.
There is the 3rd option with SharePoint 2010 and that is to use the Client Side object model. The client side object model a a sub set of the larger Sharepoint API, but it does cover uploading documents. Below is blog post with an example of uploading.
Upload document through client object model
As with most things in SharePoint you will need to authenticate against it the site, so find out if your site collection is forms based or claims based and then you should be able to find sample code for your situation.
Solution to the problem:
The problem was that the "security token webservice" was not working and it was giving some error when we manually ran the webservice.
The server was unable to process the request due to an internal error.
For more information about the error, either turn on
IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute
or from the configuration behavior) on the server in order to send the
exception information back to the client, or turn on tracing as per
the Microsoft .NET Framework 3.0 SDK documentation and inspect the
server trace logs.
The above exception is a generic one. To view the exact exception we enabled remote error viewing from the web.config file of the webservice(link) and saw the exact exception.
We found the solution for the exception and the service started. After that everything was working fine.
I am using SPLongOperation to run a lengthy operation. After completing, the gears page redirects back to the original page from which the long operation was launched. I am not able to write anything to the oriignal page using SPLongOperation.Endscript. Here is the code I am using
using (SPLongOperation operation = new SPLongOperation(this.Page))
{
//.......................
//.......................
StringBuilder endScript = new StringBuilder();
endScript.Append("document.write('Success!!');");
operation.End(Request.Url.ToString(), SPRedirectFlags.UseSource, HttpContext.Current, String.Empty, endScript.ToString());
}
You won't be able to write anything to the calling page, a new http request has been made to show you the page with the spinning wheel while your operation is under progress and then you're redirected back to the specified url (using a new request).
The easiest way to show a success message is to pass a specific querystring to your calling url by replacing your string.empty parameter with something like
operation.End(Request.Url.ToString(), SPRedirectFlags.UseSource, HttpContext.Current, "success=1");
http://msdn.microsoft.com/en-us/library/ms450341.aspx
and then on the load event, check if you have this parameter and display the relevant message (it would be better to add an item to the HttpContext.Items or doing a post instead of a get to remove the querystring but the suggested implementation will prevent you from changing your long operation call and behaviour)
Hope this will help.
Try an alert - that worked for me..
Script.Append("alert('Success!!');");
This might be of help: http://www.sharepoint-tips.com/2012/07/reporting-code-errors-when-running-code.html
SPLongOperation longOp = new SPLongOperation(this.Page);
StringBuilder sbErrors = new StringBuilder();
longOp.Begin();try
{
throw new Exception("Sample");
}
catch(Exception ex)
{
sbErrors.Append("An error occurred: " + ex.MEssage);
}
if
(sbErrors.Length > 0)
{
longOp.EndScript("document.getElementById('s4-simple-card-content').innerHTML = \"Errors have occurred during the submission. Details: " + sbErrors.ToString() + " \";");
}
//close the dialog if there were no errors
longOp.EndScript("window.frameElement.commitPopup();");