Connecting to TFS with SOAP using C++ - c++

I have a C++ (QT5) application and now I wanted to connect to TFS and get the projects and few other details of the project. The main intention is to pull out the Test Cases from MTM.
So many examples using their API with C# and easily solving this problem. However I am having no such luck with C++. I am not sure how to proceed, should I write my own web service using the SDK and then use it or does TFS provide SOAP support.
I thought it did and hence fired fiddler to get to it, but never saw an auth method anywhere. All the requests I saw was GET. And there was a NTLM authorization as shown below.
GET http://localhost:8080/tfs HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Authorization: NTLM TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAGAvAjAAAADw==
Any suggestions I can have or tips I would be grateful. I wish there was some documentation or samples/examples using C++.
If it has SOAP functions (WSDL) I could use KdSoap and use it with my application.
Thanks.

There is no way to bypass the API.
While you can connect to the web services for TFS directly there is no support for this method. Your code can break with any update to TFS. I would recommend that you create a web service with c# and then call that from your code. I would expect that the rest api's will become available on premises at some point.
Another option, although I am dubious of the support would be to create a hybrid DLL, C++ Managed, that can call the C# API's. You can then call the hybrid code from the native code. This is one extra level of wrapper and is really designed to help teams migrate from C++ to C#, but I believe that it will work.
http://en.wikipedia.org/wiki/C%2B%2B/CLI

Related

Verification with the new Google rest apis requirements (15.01.2019)

in the requirements for using the Gmail REST APIs: https://developers.google.com/terms/api-services-user-data-policy#additional-requirements-for-specific-api-scopes
There is the statement:
Do not mislead Google about an application's operating environment. You must accurately represent the environment in which the authentication page appears. For example, don't claim to be an Android application in the user agent header if your application is running on iOS, or represent that your application's authentication page is rendered in a desktop browser if instead the authentication page is rendered in an embedded web view.
We have an Electron version of our app, that is only wrapping the web version URL in a desktop app. So we are using the OAuth flow for Web Server applications for both the web app and the desktop app. Can this be considered a valuation of the User Data Policy?
The key is agent header. This corresponds with the HTTP header User-Agent.
What Google is asking is that you use a User-Agent string that matches the platform that you are running on (android, iOS, Windows 10, ...). This link will give you more information about User-Agent.
You can test what strings are included by your browser using this site. This should give you a better understanding. For example on my Windows 10 desktop using Chrome:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
This link is the RFC7231 standard.
If your software is running in the browser, you don't need to do anything except don't override the User-Agent value. If you are writing your own custom software, then do some research and specify a User-Agent string that identifies the platform and append your software / company name.
Electron publishes a list of its User-Agent strings. My initial recommendation is just leave the User-Agent header alone and let Electron manage this for you.
This StackOverflow answer shows how to set the Electron User-Agent header if you choose to do so.

How can I call a ASP.Net made web service without using MSXML?

I am using a very particular language named “Magik”, I used to use MSXML2 to run web services but in one of my projects I failed to use MSXML, I tried a lot of thing to make it work from changing MSXML.DLL and testing different version of MSXML, using MSXMLHttpServer and all the things you may think of, I somehow ate MSDN website but didn’t find anything helpfull.
Now I am looking for other ways of calling a SOAP webservice, someone said you may post your XML to web method address by parsing and using a query string, But I didn’t succeed to do so.
I can also negotiate via TCP/IP, Can I send my XML to a web service using a TCP/IP connection?
If there is any other way that do the job I really appreciate it.
Currently I am connecting Magik to a Java application and when I need to call a web service I send my request to that Java application (there is a Jar file which creates a data-bus between a Magik session and a Java Application) I have also wrote the Java part using Axis technology. But this is a very hard job and I should change a lot of things to only keep my project up and match with a small change in web service that I consume.
Using MSXML were so easy formerly, sadly it does not work now!
First note that you can not use GET to call SOAP web services only POST will work with SOAP, GET can be used for REST but you mentioned SOAP only.
I can introduce you two method that you may use to call a web service instead of your MSXML which does not work anymore.
Using Test Form (Web Service Test Page)
You may ask your .Net web services provider to create a test form for his own web service and you create a query string which suppose to emulate the data on the form, actually you are using the web services tester page to send your data via query string to it and it will complete the rest for you.
Using TCPIP
use a TCP/IP Connection, in this method you need to create a header above your xml to set the parameters that a web service consumer should fill (remember MSXML and Content-Type, Content-Length, SOAPAction, Host, …….)
then translate your string to a byte vector since all programming language which can create a TCPIP Socket just accept a byte vector while inputing or outputing data to that connection. after translating the string you are ready to send the data to your web services address.
take a look at the following example of how you may create a string to send to a TCPIP socket.
POST /globalweather.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.webserviceX.NET/GetCitiesByCountry"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetCitiesByCountry xmlns="http://www.webserviceX.NET">
<CountryName>Egypt</CountryName>
</GetCitiesByCountry>
</soap:Body>
</soap:Envelope>
You may send above string to http://www.webservicex.net/globalweather.asmx
You may check to following link if you need detailed information about how to consume a web service using TCPIP
http://www.codeproject.com/Articles/312530/Calling-Webservice-Using-TCP-IP-from-any-Programmi

How can i set up an unit testing system to test against a Web API 2?

Here is my set up and dilema
We have created an ipad application that uses an HTML wrapper to display information to the user. It is a telerik App builder solution running an HTML 5 site with JS and connect to our web API side for fetching data.
The server side is a WEB API 2 running on a web project, no Katana, just a the same modified template from the SPA sample file.
The way the user authenticates on the IPAD is by issuing a /token request. In fact here is the
actual fiddler traffic when the user request a token
POST http://development01/MobileAPITest/Token HTTP/1.1
Host: development01
Connection: keep-alive
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept-Language: en-us
Accept: */*
Origin: file://
Content-Length: 57
Connection: keep-alive
User-Agent: Mozilla/5.0 (iPad; CPU OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 (391865488)
grant_type=password&username=johndoe&password=pass1234
So. How can i set up a test system to test this at the http level?
I assume you want to test the Web Api itself?
You shouldn't have a need to test the controllers via HTTP protocol, the framework has been tested to work up until the point of giving your method a request object and a deserialized version of the incoming model.
Setup a test project for the site and test the controller functionality by directly issuing commands to the controller methods. This relieves you of the burden of having a HTTP client mixed with the testing.
If you necessary want to write tests that include calling the API via HTTP then I suggest you either use a HTTP client to call your API from the test project.
A good step-by-step unit testing tutorial for ASP.NET Web Api 2 can be found here:
http://www.asp.net/web-api/overview/testing-and-debugging/unit-testing-with-aspnet-web-api
And for testing with routing:
http://www.asp.net/web-api/overview/testing-and-debugging/unit-testing-controllers-in-web-api

Apache Http Server POST 400

that's my first question here. After long research, I decided to ask for help...
So first I'll explain my scenario. I have some SOAP web services here. They're consumed by an .Net website. The .Net framework used is in version 4.0.
So my web services are configured to accept HTTP/1.0 protocol, due to .Net limitations. In spite of that, everything works fine if I access the service directly to Jboss AS(4.2.2 GA).
But, I have to make it work with Apache web server as the receptor of the request. Apache do a inverse proxy redirection to my service, so the site send requests to port 8080 (that Apache is listening) and send it to jboss that is expecting the request at port 18080.
In many tests, I confirmed that almost every service worked almost fine, sometimes they have the same failure. But one in particular don't work anyway, the request stopped at Apache with status 400 and empty value (the - after the 400) like that:
POST /xxxx/xxxx/xxxxx/MyService HTTP/1.1" 400 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; MS Web Service Client Protocol 4.0.30319.296)
The other requests that are processed have this value filled. I guess is the response size.
Please consider my regards. thanks
After great efforts at my company we discovered using an Sniffer(Wireshark) that we had two problems that let us to had the situation described in this problem.
First problem solved: .Net platform is configured to send by default an empty request. The first attempt failed so .Net was forced to automatically send a second request with authentication. So i figured out 2 requests before the Jboss response formed an http 400 error.
Second Problem solved:
After the other side solved thise previous problem configuring .Net properly, we tested again and the results were conclusive that no more requests was hitting Apache Http Server. - So there was a strong signal that we had something blocking this specific service. With the rocks in my hand, infrastructure people started to move their asses and somehow solved the problem. Mine frustration in the end is that they didn't said nothing about the possible correction. So "suddenly" the communication was restored..
So after all we made it! but with a bitter taste of defeat. Thank you all that supported me in this problem. []s

Remove XOP gunk from WS Response in Silverlight 3

I have a Silverlight client that I need to call a web service. The web service is built in Java and uses XOP encoding to attach binary messages to some of its calls. However, the Silverlight service only uses calls that do not include any binary encoding. However, since I have no control over the web service, I must still deal with the XOP multi-part message - (an example of one is below).
Example response from web service (data stripped out)
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:890535d9-d11f-4dfb-8393-789e20ea8064"; start="<root.message#cxf.apache.org>"; start-info="text/xml"
Date: Thu, 27 Jan 2011 22:03:09 GMT
Content-Length: 47247
--uuid:890535d9-d11f-4dfb-8393-789e20ea8064
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <root.message#cxf.apache.org>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:Response xmlns:ns2="http://tempuri.com/"></ns2:Response>
</soap:Body>
</soap:Envelope>
--uuid:890535d9-d11f-4dfb-8393-789e20ea8064--
Our current implementation manually constructs a soap message using string replacement and uses the WebClient class to post the request and download the response as a string. We're then stuck with manually parsing the data as XML. This is ok, but it's a bit difficult, and we have REST services available for that anyway; I'd really like the service proxy to respond with objects.
What I'd really like to do is implement a custom behavior that will intercept the message before the WS stack tries to deserialize the SOAP and remove the XOP gunk, but so far I have found nothing that will allow me to do such a thing.
The way I see it, I have a few options:
Create a proxy service on the server (that I control) that will resubmit the request to the Java service and can actually handle the XOP. This option has performance implications that I'd like to avoid.
Implement a custom MessageEncodingBindingElement, MessageEncoderFactory, and MessageEncoder that will handle the XOP. This option seems like the best at first, but since I cannot extend the TextMessageEncoderFactory or TextMessageEncoder (they are internal classes) I basically would need to rewrite the entire message encoding from scratch (Thank you very much Microsoft!).
Leave the thing as it is.
Are there any options that I'm not seeing?
Nope, there's no other alternatives.
I've decided to implement a pass-through ashx proxy that will use the WebClient.DownloadString() method then parse out just the SOAP and plug that into the response. It should be flexible enough, and best of all, I can just use the autogenerated proxy classes from Silverlight, then just make the endpoint use my ashx proxy - which makes maintenance much simpler.