How to find the Servers response in a C# ClientBase with BasicHTTPBinding - c#

I am using C# with Visual Studio. I have imported a WSDL file into my project, so that VS automatically created a class for me to use the appropriate services.
Now I got an error from the server and for debugging purposes I would like to see the RAW response of the server. It looks that this is quite complicated to obtain.
Please take a look at the screenshot below:
I've got only the "base.channel" object. But also after a long time of digging into all the attributes and sub-objects, I'm still not able to find the actual servers response.
The code on line 6776 is the first and only one where I can stop. So there is no possibility to look into some objects earlier.
I'm quite new to Server Client based applications with C# and WSDL. I really hope, that the mechanism, how the requests work, are always the same, so that someone could give me a hint how I can retrieve the servers raw response.
Since it is HTTPS, wireshark is no option.
Thanks

Found the solution:
I used Fiddler which is able to decrypt also SSL traffic!

Related

System.Net.WebException: 'The server committed a protocol violation. Section=ResponseStatusLine'

I'm trying to contact an HTTP endpoint used to remotely control a smart strip. Everything done locally in my LAN, and i figured out using an HTTP proxy, that calls are done directly to the strip if the client device is connected to the same WLAN network.
I tried to call the endpoint using Postman and did work like a charm. It just took me to copy the proxy-intercepted body and make a POST.
Now I'm trying to make the same call from some C# code, and I'm getting the exception shown in the question title.
I found another post here on SO that shows a way to solve this by changing something server-side, which is not an option in my case. Any ideas on how can I solve this?
I already tried to include all the headers Postman generates automatically, but nothing did help.
Also using different libraries to achieve http communication (RestSharp, native WebRequest) i obtain always the same result.

C# - .NET SOCKS 4/5 Support [duplicate]

According to my research whilst trying to solve this problem, it turns out that the .Net WebProxy class does not support Socks proxies - a tad annoying. I also can't seem to find any code or information which explains how to implement Socks 4/5 support via a class which can easily be used with HttpWebRequest (the Proxy property, to be exact).
I've found limited information via google on how I could do this. One suggestion involves changing internet explorer proxy settings - something I'd rather not do.
Does anyone know of anything which could do the job or have any suggestions? Any help would be much appreciated.
I tried numerous .Net libraries which claimed to support Socks4/5 but found many of them just did not work or would error trying to connect to proxies I knew were functioning.
I've ended up using Chilkat Software's Sock/SSL component which seems to work well for me even if I do have to manually construct the HTTP requests instead of using HttpWebRequest as I would have liked.
Update note: Chilkat.Http (similar to the HttpWebRequest class) does inherently have support for SOCKS proxies. So don't spend time trying to code your own HTTP requests as I did; just use the Chilkat.Http.SocksHostname, Chilkat.Http.SocksPort and Chilkat.Http.SocksVersion properties.
Changing IE's proxy settings won't help you at all-- the other poster was just observing that it works for IE. Because the .NET Framework doesn't support SOCKS, you'd have to write your own CERN-Proxy to SOCKS-Proxy converter, such that .NET talks to the CERN proxy (the type it supports) and your code converts that to a SOCKS proxy call.
FWIW, this is something I'm presently looking to add to FiddlerCore (www.fiddler2.com/core) because I already have almost all of the code. The only thing I really need is a SOCKSv4a proxy to test against.
Since .NET 6, socks proxies can be used natively with HttpClient. See this issue on GitHub.
Use Privoxy or same to create http proxy gateway to your socks.
Add this to main config to chain Privoxy and socks:
forward-socks5 / proxy_host:port .
And something like that to enable direct access to your local network:
forward 192.168.*.*/ .
forward 10.*.*.*/ .
forward 127.*.*.*/ .

Yahoo Messenger servers for use in API

I'm making a C# Wrapper for Yahoo IM API. Sometimes when I'm using the server developer.messenger.yahoo.com, it gave me errors (4xx or 5xx).
After hours searching on the web, I found this link https://help.yahoo.com/kb/SLN1227.html. The link contains information about Yahoo Messenger Servers, Port and Protocols.
I want to know can I use these servers to replace developer.messenger.yahooapis.com server?
In the link you've posted, the configurations are supposed to be used by the IM client itself, not to use with the API.
So, probably they'll NOT work.
In this link appear a different server: developer.messenger.yahooapis.com
Be aware that 4xx errors means that the request was malformed (problem in your side, be sure your code it´s correct) while 5xx errors means that there is a internal error in the server.

What happens in the background of a SOAP service

I've some strange problems with a web service. One problem is that I don't fully understand how SOAP works.
It seems that it is possible that two different application can connect to e.g. 127.0.0.1:8000 at least that seems possible with the code that is generated with the .NET WSDL tool. But IMO only one application is allowed to bind to a port and listen to HTTP responses. Do the .NET classes do something silently?
For a tiny test I tried to do everything on my own with the HttpWebRequest class to see where the problem is. I get some 500 StatusMessages from the Webserver that the EndpointDistpacher is unable to find an AddressFilter (I think it's probably an .NET exception for the server transfered over HTTP). I copied the SOAP request from another client that works. What I here do not understand. Does the server probably open another new connection to the client, instead of answer to the already open connection?
I don't seek direct answers for my problems. What I really wonder how TCP/HTTP is used in the background for raw SOAP and for WS-Adressing. And what I've to do, to create a simple stupid client, assuming that I only have a TCP/HTTP class.

Question about C#, servers, XML

So I'm working on a project for my internship and have hit a bit of a brick wall. Unfortunately, the only people I know who are qualified to help me at the office are on vacation at the moment, and Google has been unfortunately unhelpful (or my search skills inadequate), so I thought I'd ask here.
The project is basically to make a server to mimic one that the company (which makes phone apps) already has. What I need to do is have one of their apps send a request to my server (I will have to modify the app to do this, but don't know how), and have my server reply with an XML response that the app already knows how to process. (The main purpose is so that we can see how the app responds when the real server sends it an error by simulating it on my server.)
Now, I already have a few sample HTTP requests and their associated XML responses handy, taken from simulations with the app and the real server. The app is written in C#, and currently sends HTTP web requests to the real server's online location, which responds to these HTTP web requests with XML. My server, however, will not have an online location, so the app will have to be modified to work with sockets on a local host.
My questions:
1) My boss said to create an XML file to associate certain requests with certain XML responses, but I have no idea what he means or how to do this. (He said it could also be done with a .ini file.) Does anyone know?
2) Once I have this XML file that can make these associations, how can I incorporate it into my server so that my server can check the request it received against its table of valid requests and figure out which response to send back?
3) How can one modify the app from using HTTP web requests and responses to using sockets?
If you have any questions/clarifications that you need in order to better answer this, please don't hesitate to ask me.
Thanks!
What you're describing is a web service. Unfortunately, his advice to change a setting in an .ini file make it sound like they have a proprietary system for doing this, rather than using a standard ASMX (which requires IIS) or WCF (which can either run in IIS or as a standalone service, which it sounds like is what you'd want) service.
Without more information about what they're using, I don't know that you'll be able to get much help here.
In response to question #3:
HTTP is a protocol that already runs on a specific socket (normally using port 80).
An internet socket is an endpoint that is used to transport data between processes. If you want to run your own protocol, you will need to create a new socket (with TCP or UDP) on a specific port.
This will however require you to create your own client and server in order to exchange data between them.
To get started, here is a very simple client-server example in C# using a custom socket.
Good luck!
Ask your boss if this client communicates with soap, if so then just go to MSDN and find tutorials on implementing an ASMX webservice, follow the tutorial through and you'll have a shell to start with.
First I'd like to say that it sounds like you have some unclear requirements that you should probably clarify with your boss. If you're not exactly sure what he means you should find out because nothing sucks more than having to support someone's creative interpretation of requirements.
1) It sounds like your boss just wants a way to easily change associations for testing without having to rebuild the app so he's asking you to store those associations in an xml/ini file that can easily be modified. In c# you can easily go between XML and DataSet objects so this should be trivial. I would create the data structure in a DataSet first and then use the GetXml method of the DataSet to output the xml format.
2) In .NET you can store objects in Cache and create a Cache Dependency that is a file association. Thus whenever the file is modified the Cache is purged. Whenever your program handles a request it pulls the object from Cache, if the object isn't in Cache then you have a condition block rebuild it from the xml/ini file on disk. I would have that condition block call out to a function that then loads the above mentioned xml format into a dataset that is then stored in the Cache with a Cache Dependency.
3) If you are trying to test an applications i/o, modifying it to use a different transport layer sounds like a bad idea. If the app currently works over HTTP to send requests then just route the HTTP request. I would suspect that the app probably has a configuration somewhere defining the path of the webservice it currently calls out to, once you know what that path is you can either change it, or if that's not possible setup a DNS rule on the server running the app to route it to the location of your application. On windows this is as simple as adding a line to the hosts file.

Categories

Resources