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.
Related
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.
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!
I'm trying to create a server based around the restful api (basically a client - server system which listens on a specific port but all the tutorials I've seen were using asp.net, some databases or not suited / too complex.
I've tried The Msdn Tutorial, That One CodeProject and That Other CodeProject Tutorial and also haven't found a simple solution here either.
I was thinking of a solution like:
Server listens on specific port for restful requests (Lets call it "ServerListener") and handles the request then in a static "CheckNumber" if its either positive or negative. It'll then reply to the client with the value "positve" or "negative" (depending on its value). The client then shows a MessageBox with the result.
The final idea would be having the server being proxied by an nginx server which handles the the encryption with the client and sanitizing the request.
Please check https://msdn.microsoft.com/en-us/library/windows/desktop/aa364510(v=vs.85).aspx
The Http API will give you the freedom to implement your server without Asp.Net, without WCF, and even without IIS.
Check my post, it contains several examples for simple REST server implementations, including C#, Java, PHP and node.js.
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.
I'm writing UI to test an asmx web service. Server and client are .NET. Client proxy has been generated using wsdl.exe.
I would like to intercept and store a string representation of outgoing and incoming SOAP messages generated as a result of calling methods on the web proxy, so I can add a feature to the UI which will show the message just sent/received.
I dimly recall there are two pairs of extension points where code can can be added to intecept the message but I cannot remember how this was done. I think the examples I have in mind involved compressing some part of the message on the client and the reverse on the server, even though in my scenario, I want to store rather than alter the message.
Any hints and help gratefully received.
(I've partially implemented a SoapExtension. I don't understand how the ChainStream method works, and I'm not sure how to notify a listener that a soap message has been trapped (since I'm not in control of instantiating the soap extension).'
You're on the right track with SoapExtension. Did you see the documentation and example here? http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension.aspx
The idea with ChainStream is you get passed the network stream that the request would be written to, and you have the option of returning a different stream. So if you want to save a copy of the request, return a MemoryStream, which the web services client will write the request into, and then in the ProcessMessage call you can copy the data out of there and pass it to your UI.
Another way to capture the XML is sent through the Wireshark application. It intercepts the communication network card.
In my case, I called a service that had as part of his address to string PIOSOS. I used the Find Packet window and searched.
Then located the XML.
See the picture.
(I know ... it's not a programmatic way, but it has its value. Lol)
I would suggest 2 tricks :
subclassing the proxy and overloading your methods (a little bit boring but you can generate code like in this project : http://ftwsf.codeplex.com/)
using Async signatures and subcribe to 'Completed' events of each methods (you can do this by reflection to avoid writting to much code)
If you need more info about these tricks, just let me know.
You'd really be better off using WCF as your client technology. You could then simply use WCF message-level tracing to log the incoming and outgoing messages. This is done simply through configuration.
There's no reason you have to use an ASMX client just because you are using an ASMX service.