SugarCRM C# set_relationshp - c#

I am using SugarCRM v.6.5.16
Soap: http://{CRM Path}/service/v4_1/soap.php
I have been tasked to create a program that reads values from a JSON string to input into SugarCRM.
The object creation of Account, Contact, Opportunity etc. is working just fine. I am however unable to the the set_realtionship or set_realationships from the SOAP API to work.
If possible could someone give me a quick example of how to make this work.
I have found very little documentation regarding coding in C# and SugarCRM SOAP functions. I can directly insert into the 'link' table but would prefer to utilize the API since somebody took the time to write it.
If REST would work better than SOAP an example of that would also be useful.
Thanks

It is with sights for the future recommended by Sugar to use REST. Advantages are that REST is faster than SOAP and REST will live longer in the product SugarCRM.

Related

Parsing JSON data from Restful API C#

So I have implemented a C# RESTful API for a recent side project and I have noticed that when making a GET request to the API I am provided with a lot of data when I only need around 8 or so entries, specifically the newest entries.
I have narrowed down this too one of two different issues, I believe my below fall back code to be somewhat primitive following a generic class structure that is created when deseralize object is called. The main problem could be because I am using a web client to download the JSON data then passing it over, could this be more sophisticated to allow the functionality I want?
using (WebClient wc = new WebClient())
{
var json = wc.DownloadString("//api call here");
jsonData = JsonConvert.DeserializeObject<List<T>>(json);
}
I am of course using NewtonSoft Json libary here.
Or secondly could it be that I need to make changes to the controller to allow a way for me to request only the 8 newest entries? I have little knowledge of changing API's other than allowing the VS magic to happen.
I mostly seek you're advice here because I could be worried about nothing but I just think my approach is wrong and if the data starts getting larger I should be improving on my existing knowledge.
To provide clarity on how this problem was solved it was mostly done through creating specific triggers on the existing API that allowed SQL to be run which is something that was I previously didn't know.
This allowed me to limit the amount of data that was returned through a generic sql command. A separate call was created on the API which returned all of the data and loaded the later objects into the dom using an async function.
Yes you can use SQL with api's generated by C# magic.

get raw xml response from amazon mws api

I am developing a software solution using Amaon mws api in c#, using the classes from their c# library. I would like to get the xml response info in raw form, not thru their classes which are a little clumsy for my needs. Is there anyway to get out the full xml info from the response object? Please reply
They've made it easy by serializing everything into objects for you. You can go through their Sample cs file (MarketplaceWebServiceProductsSample.cs for the Products API) and dig out the method you want to call and put it into your own app, and then make the call, get back the serialized objects and then you can do what you want with them, no need to look at raw XML.
However, if you want to, just add the code that is in the runtime-src folder of the client library to your project, set a breakpoint and step into the code. You'll find it in there eventually and then copy out the parts you need.
I've written about a dozen client applications that use the various MWS client libraries and I find them easy to work with. If you don't like their classes, just write a method that converts theirs to yours.
Im not very sure about C# library.But you can get raw xml response over http connection. You can refer this:
http://docs.developer.amazonservices.com/en_IN/feeds/Feeds_GetFeedSubmissionResult.html
All the best :)

.net wrapper for OData to access any data source

I am looking for an OData wrapper in C# that can talk to any OData datasource and return the result as properties instead of the raw XML. I looked at http://odata.codeplex.com/ but it is designed around the concept of pointing to a specific datasource and building code that maps to it.
We need to create code where at runtime we are pointed to an OData datasource and read the metadata and then interactively call it with queries and then use the returned data. (I also believe Linq won't work for us because we have end users creating queries once we connect - no writing code and compiling.)
Is there anything out there?
thanks - dave
I assume you want to consume arbitrary OData service as a client, right? For that I would suggest using ODataLib (http://www.nuget.org/packages/Microsoft.Data.OData). It is a reader and writer for OData, nothing more. So it will require more code from you as compared to the WCF Data Services, but it allows consuming arbitrary OData payloads without the necessity to generate the matching types. You might also want to check out this blog for the start: http://blogs.msdn.com/b/astoriateam/archive/2011/10/14/introducing-the-odata-library.aspx
You might have to write a custom provider for what you are trying to achieve.
The following blog series are pretty helpful:
http://blogs.msdn.com/b/alexj/archive/2010/01/07/data-service-providers-getting-started.aspx
http://blogs.msdn.com/b/vitek/archive/2010/02/25/data-services-expressions-part-1-intro.aspx

How can I retrieve SoapEnvelope information just from the URL of web services in C#?

Basically I am trying to make a generic client which will retrieve the Methods Names, Parameters that it takes and Parameter that it returns from the any kind of web service. I thought of parsing the WSDL xml for that, but in that the required information is scattered over different elements. then I saw the SOAP Envelopes which contains the exact information I need. so I thought of downloading the web service page and doing the series of string operations so that I get extract the data I need from particular tag. but I guess there might be any C# functions which can give me this data containing the Request and Response headers information.
Can anybody please guide me.
Thanks in advance.
The only valid approach is through WSDL because it is the only real description of the service. Those "help pages" are just a feature of ASMX. WCF for example doesn't have this help page showing examples of SOAP messages. Also examples of SOAP messages don't really cover the whole content of the message - it doesn't correctly show which elements are mandatory and which are not. It doesn't correctly show advanced features like XSD choices etc. If you want to write generic client you must parse WSDL. It is really BIG task. Also be aware that WSDL can reference other WSDLs and XSDs.
To make things much more easier you should check available classes in .NET framework to deal with service descriptions. For example System.ServiceModel.Description.MetadataExchangeClient and other classes from that namespace.

Not sure how to send complex data using Web Services

I've looked at quite a few of the questions on the site, but I'm still having trouble fulling understanding where to begin.
I've never done anything with webservices before, so bear with me.
The current project I've been assigned is to write a webservice that queries a database and returns the data back to the client. (using .NET 2008 programming in C#)
So far, I've been able to do basic data types no problem, but I'm not 100% sure where to go from there. I've been returning an XmlDocument type, but I'm not sure that that's the best way, or even the correct way to do it.
Currently creating an ASP.NET Web service, though it's been suggested I use a WCF Web service.
Can anyone shed light on where to go from here? Or perhaps a a link to a tutorial on sending and recieving large amounts of data via webservices?
EDIT: The answers are great so far, but I'm still not 100% sure how to answer. I think the webservice will be interacted with a combination of client programs, but also websites, if that is all possible... That's how new I am to this.
Depending on the structure of the data that you're sending back to the client, I wouldn't recommend using XmlDocument as the return type. It will add a lot of unnecessary bulk to your response.
You really didn't state the protocol that you want to support, but if you're transporting data via HTTP, then sending your data back to the client as a JSON-formatted string would streamline it better.
You can define that you're returning your complex type formatted as JSON like this:
[WebGet(ResponseFormat=WebMessageFormat.Json, UriTemplate="GetComplexObject/{id}")]
public MyComplexType GetComplexObject(int id){
//do work to get your object
return myObject;
}
WCF will take care of serializing your object as JSON if MyComplexType is defined as a DataContract...
[DataContract]
public class MyComplexType{
[DataMember]
String Name {get;set;}
}
If you're looking for REST-ful services, then WCF is probably the preferred approach using the WebHttp functionality.
The WCF team put together a great series of walk-throughs on using WCF WebHttp (which is new to .NET 4). They assume a little knowledge of web http programming, but they're pretty good and hopefully help put you on the right track.
I hope this helps!! Good luck.
http://msdn.microsoft.com/en-us/library/ms733127.aspx
WCF uses this concept of a data contract - which provides serialization help on complex objects.
If you decide to use WCF there is a tutorial available at : http://dotnetslackers.com/articles/ajax/JSON-EnabledWCFServicesInASPNET35.aspx .
In general, this article gives a walk through of building an ASP.NET web service that sends JSON.
JSON is faster than XML, and is becoming a standard for most new web services. I highly recommend the JSON.NET library for JSON serialization.
There are two ways that I have implemented this using a regular ASPX.NET web service:
Have the same underlying object libraries on the client and the server and functions to translate the data from the web service object to the client object.
Have the same underlying object libraries on the client and the server and pass data to/from the server as a string representation of the data object (usually XML format, but could be JSON or another similar format)
The first option I found is VERY cumbersome. The web service will claim that its versions of the libraries are unique, even if you have the same classes/objects on both the server and the client. Even if the namespace is the same, the object returned from the web service will have the web service namespace in it somewhere, so you have to write functions to convert them. I know of a way to fix this, but it is not worth the effort, at least not for me.
The second option is the one I am using right now. I again have one library on both client and server. It has objects that get and hold data from the database. I then have generic utility functions that serialize objects to and from XML strings. When I send data from the server I serialize it to an XML string on the server and deserialize it at the client. I do the reverse when sending data to the server. I also break up large amounts of data being passed to/from the web service to reduce errors and data transfer time.
WCF may be better. Never used it. But the above is what I have done with standard web services.
The best way to send data back to client it's throught xml, because almost all languages know how to handle xml document.
If you want to return something that it's in some way language dependent is't not worst to implement if you want your web service to be implemented using virtually all languages posible.
Another posibility is to return json objects.

Categories