Netsuite SuiteTalk - Login - suitetalk

I am trying to use SuiteTalk to retrieve customer records.
I downloaded the v2016.1 WSDL from here: http://www.netsuite.com/portal/developers/resources/suitetalk-documentation.shtml
I used mv package to build the WSDL and generated the jar file.
I create a project in Eclipse and added the jar file. I am using Java.
Here's a snippet of my code. I am stuck here and don't know how to proceed. It looks like I am missing another jar file? like the NetSuiteService?
RecordRef role = new RecordRef();
role.setInternalId("3");
role.setType(RecordType.contact);
Passport passport = new Passport();
passport.setEmail("me#test.com");
passport.setPassword("mypassword");
passport.setRole(role);
passport.setAccount("123456");
Please help me. What do I need to do?

I'm not familiar with the Java bindings, but it looks like you are missing the data center URL configuration.
I'd recommend using the ruby bindings. They are community supported and there's some decent example code demonstrating various common functions.

I work with .net, I think you need to initialize the service to indicate the datacenter that corresponds to you, it is more or less like this:
// Instantiate the NetSuite web services
Service = new Aggregates.DataCenterAwareNetSuiteService(_account);
Service.Timeout = 1000 * 60 * 60;
var appInfo = new ApplicationInfo();
//App info from application netsuite
appInfo.applicationId = cuenta.ApplicationInfo;
// Prepare login credentials for request level login
Service.passport = new Passport()
{
email = _email,
password = _password,
account = _account
};
Service.applicationInfo = appInfo;

Related

Java method is successfully executed inside a Java agent, but fails if executed in a Java class in the database's code

In my XPages application, I use the javax.mail library to read mail messages from IMAP accounts. The class I use to get and save messages works perfectly fine if I use it inside a Java agent. However, if I put the exact same class into "Code/Java" in my XPages project, the methods throw javax.mail.NoSuchProviderException: No provider for imaps when I try to get the session store:
Properties props = new Properties();
props.setProperty("mail.imaps.socketFactory.class", "AlwaysTrustSSLContextFactory");
props.setProperty("mail.imaps.socketFactory.port", "993");
props.setProperty("mail.imap.ssl.enable", "true");
props.setProperty("mail.imaps.ssl.trust", "*");
URLName url = new URLName("imaps", server, 993, "", username, password);
Session session = Session.getInstance(props, null);
Store store = session.getStore(url); //THE ERROR OCCURS HERE
store.connect();
The javax.mail library that I added to the project's build path is exactly the same that I use in the Java agent.
Some posts I found for the mentioned type of exception suggest that it might be caused by multiple versions of javax.mail being included in the build path. However, this does not seem to be the case because removing javax.mail from the build path causes the class to not be built.
Does anybody know what's the problem here?
Please check the versions and providers of javax.mail used. You can do this by adding
props.setProperty("mail.debug", "true" );
to your properties.
On the console (Client's Java Console or Server console you can see the result, something like this:
DEBUG: JavaMail version 1.4ea
and
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
Alternativly, you can get the list of available providers programmatically (when you have no console access):
Session session = Session.getInstance(props, null);
Provider[] providers = session.getProviders();
for( Provider p:providers ){
if( ! ("".equals(tmpStr)) )
tmpStr = tmpStr + ",";
tmpStr = tmpStr + p.getProtocol();
}
[You will see that the list of providers does not contain imaps on the server (8.5.3)]
Was going to comment, but rep isn't high enough yet....
Is the java agent in the same db?
If it is, can you cut it and try the xpage when the agent isn't there? Probably a long shot, but may be worth checking that the agent isn't interfering in any way.
You want to check out my article with a code sample how to read IMAP from Notes. I didn't run that code as agent, but from the command line. Chances are, that it will work better for you. Main difference (possibly?): I used the Google enhanced IMAP classes.
Check it out and let us know if that worked for you!

Connect with Visual Studio 2012 and C sharp to microsoft cloud TFS server

I am building an asp.net webforms site that can connect to our tfs hosted on Microsoft (http://companyname.visualstudio.com) and get data from it. When I run the project with Cassini it runs fine as it gets the authentication from the browser. But I want to do this from code behind.
I have tried various setups like
var tfs = new TfsTeamProjectCollection(CollectionUri, new UICredentialsProvider());
[which is now deprecated as method and should not be used]
or
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(CollectionUri);
or even with
var tfs = new TfsTeamProjectCollection(CollectionUri, new NetworkCredential("windowsliveid","password"));
I have no domain since it is a Windows Liveid
and then
tfs.EnsureAuthenticated();
Also I get the uri through
var CollectionUri = new Uri("https://companyname.visualstudio.com/DefaultCollection/");
Any ideas on how to properly authenticate. I would love to either prompt the auth window or give username and password directly.
------------------------------ SOLVED !!! ---------------------------------
Here is the solution to it after some googling following Martin Woodward's very helpful suggestion.
First alternate credentials have to be activated through the TFS account. Then the code can be changed into this which works fine :)
Just remember that you need to have the latest version of VS 2012 (at least update1) for the code to work. Else you can't reference BasicAuthCredential.
var nc = new NetworkCredential("username", "password");
var bc = new BasicAuthCredential(nc);
var tfsc = new TfsClientCredentials(bc) {AllowInteractive = false};
var tfs = new TfsTeamProjectCollection(CollectionUri, tfsc);
tfs.Authenticate();
And here are the referenced dlls.
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
Take a look at service credentials, or try enabling alternate credentials on your account which will then allow you to authenticate using http basic auth.
You probably want service credentials for what it sounds like you are doing though.

Enterprise Library Security Block

Does anyone know if there is a way to create the security configuration section via the Enterprise Library API or do we have to use the config wizard / edit by hand?
Yes, you can configure any section via the new fluent interface.
Just use ConfigurationSourceBuilder. Like so:
var builder = new ConfigurationSourceBuilder();
builder.ConfigureSecurity()
.AuthorizeUsingRuleProviderNamed("MyRules")
.SpecifyRule("Rule1", "MyRuleExpression")
.CacheSecurityInCacheStoreNamed("SecCache")
.WithOptions
.UseSharedCacheManager("MyCacheManager")
.SetAsDefault();
var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current
= EnterpriseLibraryContainer.CreateDefaultContainer(configSource);
You even get IntelliSense support.
More info on MSDN

Execute SPDatasource query in Console App?

Is it possible to execute an SPDataSource object query in a console app for testing?
e.g.:
SPDataSource source = new SPDataSource
{
UseInternalName = true,
DataSourceMode = SPDataSourceMode.List,
SelectCommand = "<View/>"
};
source.SelectParameters.Add("WebId", TypeCode.String, "rootweb");
source.SelectParameters.Add("ListName", TypeCode.String, "Contacts");
var c = source.GetView();
var d = c.Select();
I think the context info is missing but can't figure out how to add it?
I just looked at it in Refelector and it ends up creating a class called SPDataSourceView which depends on SPContext.
I have never been able to creat an SPContext from a console application because of constructors marked as internal.
One option would be to put your class into a Web Service that is deployed to your SharePoint Farm. Then have your console application call this Web Service. However you might be better off using one of the Out of Box SharePoint Web Services.
I´m not sure what you´re after here, I mean
Testing your SPDataSource in console app (nothing to do like said by JD)
Getting data from sharepoint in a datasource manner.
If your´re going for solution 2 you could use a linqdatasource instead of the spdatasource.
See my post on this if that´s what your´re looking for.

Upload a file to SharePoint through the built-in web services

What is the best way to upload a file to a Document Library on a SharePoint server through the built-in web services that version WSS 3.0 exposes?
Following the two initial answers...
We definitely need to use the Web Service layer as we will be making these calls from remote client applications.
The WebDAV method would work for us, but we would prefer to be consistent with the web service integration method.
There is additionally a web service to upload files, painful but works all the time.
Are you referring to the “Copy” service?
We have been successful with this service’s CopyIntoItems method. Would this be the recommended way to upload a file to Document Libraries using only the WSS web service API?
I have posted our code as a suggested answer.
Example of using the WSS "Copy" Web service to upload a document to a library...
public static void UploadFile2007(string destinationUrl, byte[] fileData)
{
// List of desination Urls, Just one in this example.
string[] destinationUrls = { Uri.EscapeUriString(destinationUrl) };
// Empty Field Information. This can be populated but not for this example.
SharePoint2007CopyService.FieldInformation information = new
SharePoint2007CopyService.FieldInformation();
SharePoint2007CopyService.FieldInformation[] info = { information };
// To receive the result Xml.
SharePoint2007CopyService.CopyResult[] result;
// Create the Copy web service instance configured from the web.config file.
SharePoint2007CopyService.CopySoapClient
CopyService2007 = new CopySoapClient("CopySoap");
CopyService2007.ClientCredentials.Windows.ClientCredential =
CredentialCache.DefaultNetworkCredentials;
CopyService2007.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Delegation;
CopyService2007.CopyIntoItems(destinationUrl, destinationUrls, info, fileData, out result);
if (result[0].ErrorCode != SharePoint2007CopyService.CopyErrorCode.Success)
{
// ...
}
}
Another option is to use plain ol' HTTP PUT:
WebClient webclient = new WebClient();
webclient.Credentials = new NetworkCredential(_userName, _password, _domain);
webclient.UploadFile(remoteFileURL, "PUT", FilePath);
webclient.Dispose();
Where remoteFileURL points to your SharePoint document library...
There are a couple of things to consider:
Copy.CopyIntoItems needs the document to be already present at some server. The document is passed as a parameter of the webservice call, which will limit how large the document can be. (See http://social.msdn.microsoft.com/Forums/en-AU/sharepointdevelopment/thread/e4e00092-b312-4d4c-a0d2-1cfc2beb9a6c)
the 'http put' method (ie webdav...) will only put the document in the library, but not set field values
to update field values you can call Lists.UpdateListItem after the 'http put'
document libraries can have directories, you can make them with 'http mkcol'
you may want to check in files with Lists.CheckInFile
you can also create a custom webservice that uses the SPxxx .Net API, but that new webservice will have to be installed on the server. It could save trips to the server.
public static void UploadFile(byte[] fileData) {
var copy = new Copy {
Url = "http://servername/sitename/_vti_bin/copy.asmx",
UseDefaultCredentials = true
};
string destinationUrl = "http://servername/sitename/doclibrary/filename";
string[] destinationUrls = {destinationUrl};
var info1 = new FieldInformation
{
DisplayName = "Title",
InternalName = "Title",
Type = FieldType.Text,
Value = "New Title"
};
FieldInformation[] info = {info1};
var copyResult = new CopyResult();
CopyResult[] copyResults = {copyResult};
copy.CopyIntoItems(
destinationUrl, destinationUrls, info, fileData, out copyResults);
}
NOTE: Changing the 1st parameter of CopyIntoItems to the file name, Path.GetFileName(destinationUrl), makes the unlink message disappear.
I've had good luck using the DocLibHelper wrapper class described here: http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html
From a colleage at work:
Lazy way: your Windows WebDAV filesystem interface. It is bad as a programmatic solution because it relies on the WindowsClient service running on your OS, and also only works on websites running on port 80. Map a drive to the document library and get with the file copying.
There is additionally a web service to upload files, painful but works all the time.
I believe you are able to upload files via the FrontPage API but I don’t know of anyone who actually uses it.
Not sure on exactly which web service to use, but if you are in a position where you can use the SharePoint .NET API Dlls, then using the SPList and SPLibrary.Items.Add is really easy.

Resources