c# soap and logmein - c#

As logmeinrescue doesn't support batch users creation using a simple csv upload or similar and instead offers the ability to create user accounts using http post and get or by using soap I thought I would look into this.
Unfortunately following the code example in this link I have been unable to work out how to utilize the SOAP aspect of the code as I have never had previous experience using it.
So far I have written a fairly basic program that reads in the csv with all the user account data needed for creation and would loop through and assign the values needed.
If anyone could assist it would be greatly appreciated, I have tried to look up some documentation in regards to c# and soap but I was unable to find something that really helped me with configuring for logmein.

The c# example at the bottom of documentation you link to looks helpful but flawed. APISoapClient does not have a CookieContainer property so I would try it without the line of code that tries to set it. Later in the code there is a call to sAPI.createUsers but the example has not defined sAPI, I think they meant to re-use proxy.
To get started the easy way, right-click your project References and select Add Service Reference. Enter their endpoint and click GO:
https://secure.logmeinrescue.com/api/API.asmx
If you change the namespace from Service1 to match the example (APIServiceReference) your code will look like the example. From then on you can perform API operations basically just like you were dealing with classes, the SOAP mess is abstracted away for you.

Related

Add rel="nofollow" automatically to all outbound links in ASP.NET

Any geniuses on StackOverflow ever made a solution which automatically adds rel="nofollow", to all external links?
I'd just like to apologise, I'm very new to backend coding - my attempts have literally got nowhere hence why I haven't posted them.
I've found some solutions in php, but nothing in ASP.NET.
I have a solution in jQuery, but the issue is - it'll be added after load. This is no good for telling Googlebot to ignore said links on my pages.
The jQuery solution is:
$("div.content a[href^='http']:not([href*='mysite.co.uk'])").attr("rel",
"follow");
One way would be to create your own custom HttpModule that set's the response to use a derived stream class to filter the HTTP body. There is a linked example in there on how to create a basic HttpModule. Github or Nuget may have a filter class that someone has written to do modifications the output stream when it's content type is text/html that you might be able to modify for your needs.
To build one on your own you will essentially need to attach to the BeginRequest event and set a filter to the HttpApplication's response.filter. That filter will be in charge of implementation of reading the response the page/control/ihttphandler has created and modifying it before it sends it to the client and then implementing the write to the client.

Getting the XML request from ClientBase<T>

I am currently using ClientBase to access a web service. This works correctly but I need to log the XML request that is being sent off to the service.
I can see that there are ways of doing this using listeners and other similar methods, but I need to access this XML request in the method from which it is being submitted in my codebase.
Is there any way in which this is supported?
The "XML" is only ever created (serialized) after the control flow leaves your method and enters the WCF code that actually does the call. So if you were theoretically able to get it from within your code, you'd have to get it "after" the actual call. This is also the reason why the intended way to do this, is implement/register a IClientMessageInspector.
The only other thing, which includes some unnecessary manual labor, would be to manually serialize the arguments you pass to the WCF call using the NetDataContractSerializer or DataContractSerializer. Mind you, though that this will only give you the payload, not the complete message (including headers, etc.).
I'd really go for the way that is suggested for this (see link above).
You can try some AOP programming. If you are using Unity for DI, you can try Unity with Interception or Interception alone using Intercept class.

How do I create a simple SOAP server using C# in Visual Studio 2010?

I was trying to follow the instructions here but they seem to quickly be getting very specific to Sharepoint, as they go along further. I just want a general tutorial for creating a non-sharepoint SOAP starter projects, and Google is not my friend, at the moment.
It seems that some of the above steps are applicable.
So far I have:
A solution 'WebSite1' created with File -> New Website.
A 'ClassLibrary1' project in C#, with System.Web.Services added to References.
a key02.snk (strongname key file) file node in the classlibrary1.
No code implementing any SOAP server methods yet.
No idea how to add code to the above, and then build and run, and have a soap hello-world type method.
I'd like to implement a simple HelloWorld method that takes at least one parameter. The resulting service could be queried for its WSDL with a url like this:
http[s]://localhost/myfirstsoapserver/helloWorldMethod1.asmx?WSDL
If my guess above is right, the above Url would be usable by any tool that can import WSDL.
My goal is rapid prototyping and mocking up of various other SOAP interfaces that I need to deal with, and I'm hoping that C#+visualStudio2010+IIS is a reasonably easy way to do that.
First create a new project as a web application:
Then add a new item of type web service:
Have you considered using WCF?: http://msdn.microsoft.com/en-us/library/bb386386.aspx

Customizing the xmlns:a= tag in a soapresponse from WCF

I'm creating a service to respond to calls.
However the client(not written by me) cannot read the response.
What we have located is that this seems to be due to th missmatching namespace in the
xmlns:a="http://schemas.datacontract.org/2004/07/MyProject.Classes"
Is there anyway to override this namespace?
I'm rather sure it is.
The [ServiceBehavior] tag has the "http://correctnamespace.com" NameSpace
The BindingNameSpace in the app.config has the "http://correctnamespace.com" Namespace
The [ServiceContract] has the "http://correctnamespace.com" Namespace
I've looked at the OperationsContract to see if I can locate it but without luck.
the namespace needs to be "http://correctnamespace.com"
Below is a full example of the Upper part of the SOAPresponse
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<getAddressResponse xmlns="http://correctnamespace.com">
<getAddressReturn xmlns:a="http://schemas.datacontract.org/2004/07/MyProject.Classes" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:PropertyChanged i:nil="true" xmlns:b="http://schemas.datacontract.org/2004/07/System.ComponentModel"/>
<a:addressField>Happystreet 21</a:addressField>
I hope someone can help me sort this ut ASAP.
Added information
The service is created to fit he client.
The client is predesigned and the service is created based on a WSDL file provided from the client creator.
Also note that the client cannot be modified. :(
I have a couple suggestions.
First, assuming that the server side code sand stubs are all correct and functioning properly, ask the client to regen the client side stubs. It is possible that somehow the stub they are using is old or has been modified.
Second, if the serverside is also not working properly I recommend recreating your WSDL from scratch. Proper SOAP coding is WSDL to code creation. So if your WSDL was generated by a tool it will have a certain naming convention and while you can manually change things like your xmlns, if you miss one (which is what it sounds like happened) it will mess up your code. So go back and make the WSDL from scratch and generate the code classes from the WSDL that way you can name everything the way you want it to be named.
Based on the added information, I again have two suggestions.
First, is that you will have to go in and manually change the soap response AddressReturn namespace and follow the chain so that any references to the aforementioned response has the correct namespace. It will be tedious and annoying, but you could program an xml parser that can find any references to such field and make the necessary changes in both the schema and the WSDL.
Second is to use the WSDL provided to you by the client in order to create your own WSDL that will work with the client but has the naming conventions that you want incorporated. WSDL first coding can be done this way and is sometimes recommended because it provides the skeleton that you follow in creating and modifying to make it your own and fit your needs.
Solved by copying all the classed from the WSDL and made DataContracts of them instead, in this it's possible to define the NameSpace just like for the ServiceContract.
[DataContract(Namespace = "http://correctnamespace.com")]
public class Amount
{
Thanks for evryone who took timeto help me solve his.

Maintaining Consistency Between JavaScript and C# Object Models

I'm working on an ASP.NET web application that uses a lot of JavaScript on the client side to allow the user to do things like drag-drop reordering of lists, looking up items to add to the list (like the suggestions in the Google search bar), deleting items from the list, etc.
I have a JavaScript "class" that I use to store each of the list items on the client side as well as information about what action the user has performed on the item (add, edit, delete, move). The only time the page is posted to the server is when the user is done, right before the page is submitted I serialize all the information about the changes that were made into JSON and store it in hidden fields on the page.
What I'm looking for is some general advice about how to build out my classes in C#. I think it might be nice to have a class in C# that matches the JavaScript one so I can just deserealize the JSON to instances of this class. It seems a bit strange though to have classes on the server side that both directly duplicate the JavaScript classes, and only exist to support the JavaScript UI implementation.
This is kind of an abstract question. I'm just looking for some guidance form others who has done similar things in terms of maintaining matching client and server side object models.
Makes perfect sense. If I were confronting this problem, I would consider using a single definitive description of the data type or class, and then generating code from that description.
The description might be a javascript source file; you could build a parser that generates the apropriate C# code from that JS. Or, it could be a C# source file, and you do the converse.
You might find more utility in describing it in RelaxNG, and then building (or finding) a generator for both C# and Javascript. In this case the RelaxNG schema would be checked into source code control, and the generated artifacts would not.
EDIT: Also there is a nascent spec called WADL, which I think would help in this regard as well. I haven't evaluated WADL. Peripherally, I am aware that it hasn't taken the world by storm, but I don't know why that is the case. There's a question on SO regarding that.
EDIT2: Given the lack of tools (WADL is apparently stillborn), if I were you I might try this tactical approach:
Use the [DataContract] attributes on your c# types and treat those as definitive.
build a tool that slurps in your C# type, from a compiled assembly and instantiates the type, by using the JsonSerializer on a sample XML JSON document, that provides, a sort of defacto "object model definition". The tool should somehow verify that the instantiated type can round-trip into equivalent JSON, maybe with a checksum or CRC on the resulting stuff.
run that tool as part of your build process.
To make this happen, you'd have to check in that "sample JSON document" into source code and you'd also have to make sure that is the form you were using in the various JS code in your app. Since Javascript is dynamic, you might also need a type verifier or something, that would run as part of jslint or some other build-time verification step, that would check your Javascript source to see that it is using your "standard" objbect model definitions.

Categories

Resources