What is offered for creating a SOAP server in WCF/services? - c#

I'm trying to develop an app that works with an existing soap client. I don't think it uses any WSDL/etc. It just uses soap as a form of communication.
Example of what the client sends:
POST /SNSR_STD-SOAP HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "someCommand"
Host: 192.168.0.17:12345
Content-Length: 487
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- There is something in here obviously... -->
</s:Body>
</s:Envelope>
Now I want to be able to write a server that fetches those messages, gets the SOAPAction in the HTTP header and also the soap envelope/xml conviniently so I could reach all fields.
I started reading about WCF and services, and also followed MSDN getting started to WCF and server/client software, but it demonstrates creating a calculator service that works with wsdl etc, which is not the case here.
So the question - what is the preferred way of doing this? WCF? Services? How exactly do I launch the server, via IIS, maybe something else which is more automatic?
In the same manner, I need to write a soap client that sends such messages back to the client (which is now also a server). How do I do that?
I need the simplest most elegant way for doing this.
Thanks a lot.

You can do that, but you will have to work directly with the Message class (look at Message Headers too) and use Message Inspectors to "intercept" the message at a lower level.

Related

Reasons for SOAP message getting cutoff and header duplicated?

I have a web service that makes SOAP requests to our clients server (I do not have access to that server and have no idea how the web service methods are implemented).
The code on our part has not changed recently and has worked ok previously (and still works for most part), but the client has been reporting that a lot of our requests have been failing daily for at least a month due to "duplicate XML declaration" logged inside Data Power.
The SOAP message they receive is truncated (lots of data missing) and at the end of the XML, the initial SOAP headers are duplicated. It looks like they receive the message partially, then some error occurs, then try reprocessing it and that fails again. Basically it looks something like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sendData>
<requestHeader>
//PARTIAL INFORMATION INCLUDED HERE
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sendProspect xmlns="http://webservices.zurich.com/zsoa/fig/policyacquisition/prospectquote-v1_0">
<requestHeader>
What could cause the the SOAP message to get truncated? I am thinking about some sort of communication error between client and server, or maybe web server changes, but I was wondering if someone else has had this problems and could offer some suggestions.
EDIT: added the HTTP header received from the client:
POST <webservice> HTTP/1.1
http_racfid: <info>
SOAPAction: ""
MULE_ENCODING: UTF-8
Host: <hostInfo>
Connection: keep-alive
Accept: */*
Content-Type: text/xml
Content-Length: 41341
duplicate XML declaration in DataPower typically happens when you have a stylesheet Action in your Processing Policy that doesn't detect valid XML and it tries to "fix" it.
This would indicate that you don't get the full XML from the server.
Enable the Probe for the service and have a look at the INPUT xml.
You can also in default domain start a Packet Capture as suggested in the comments or start a File Capture to get any messages coming in. NB! Both Packet Capture and File Capture are giving a severe performance hit so you shouldn't do it in a high volume production environment!
Another, less intrusive, way of getting the "real" INPUT is to add a GatewayScript Action directly after the Match action which writes the INPUT to a temporary:/// file which you can review. This is "safer" as the temporary:/// storage cleans it self up...

Delphi <-> c# Webservice SOAP Request with missing parameters values

I need to implement SOAP communication between client in Delphi7 and .NET Webservice (ASMX). Very old projects/technnologies, I know.
I have written webservice, but auto-created class via WSDL Importer (based on THTTPRIO) is not working properly, I cant pass values of parameters into webservice. In other words, method in webservice gets called, but all its parameters have default value. I could parse xml request myself, but raw xml is not accessible in WebMethod. I hope, Im just missing some method attribute. Any idea?
I used network sniffer to ensure, that parameters are send to service, it looks like this:
POST /Lib/ASPX/WSService.asmx HTTP/1.1
SOAPAction: "WS/GetMessages"
Content-Type: text/xml
User-Agent: Borland SOAP 1.2
Host: localhost:54561
Content-Length: 480
Connection: Keep-Alive
Cache-Control: no-cache
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<NS1:GetMessages xmlns:NS1="WS">
<id xsi:type="xsd:int">12345</id>
</NS1:GetMessages>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And header of method in webservice, which gets called with parameter id=0
[WebMethod]
public List<HelpDeskView> GetMessages(int id)
I have found solution. At the end of auto-generated Unit, in initialization section, there was missing this line:
InvRegistry.RegisterInvokeOptions(TypeInfo(Service1Soap), ioDocument);

Get requests in WCF without method name

Our partner says he is going to send data using the SOAP protocol without using any service name to post data, like HelloWorld(string p1), just a POST.
So I am wondering how is it possible to do with SOAP?
I mean in WCF / web services, we need the name of method anyway, right?
Any clues? Thank you!
UPDATE #1
Using Wireshark I am getting this message
POST HTTP/1.1
Content-Type: text/xml
User-Agent: SOAP Sender v1.2
Host: 191.126.125.5:1212
Authorization: Basic QFNLVXNlcjE4MTghOiBAU0tQYTE5MTkh
Content-Length: 708
<?xml version="1.0" encoding="windows-1251"?>
<soapenv:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope">
<soapenv:Header/>
<soapenv:Body>
<ws:PutCoord>
<ObjectID>SG255108374</ObjectID>
</ws:PutCoord>
</soapenv:Body>
</soapenv:Envelope>
So what sort of .NET application I have to create to get this POSTED data?
This correspond to https://www.w3.org/TR/soap12-part0/#L26866
I was misled by my client HelpDesk. :)
They send data in SOAP format using HTTP to some port and thats it.
So... Sometimes HelpDesk is gonna confuse you. Hahahaha! Be careful!

How can I handle a custom POST origin with Nancy?

I have a third party server that POSTs data to my C# Nancy console application with the following request;
POST //172.16.100.20 HTTP/1.1
User-Agent: P2000/3.6.0
Host: 172.16.100.20:40000
Server: remotesitename
Content-Type: text/xml
Content-Length: 2744
<MessageBase>
<BaseVersion>301</BaseVersion>
<MessageType>3</MessageType>
....
However I just can't seem to get Nancy to receive the request. I've tried various catchall routes such as
"(.*)"
"{uri*}"
"//172.16.100.20"
But none of them work with the above request (they generally work from a browser or Fiddler).
I've also tried hooking in to the module and application Before handlers, but they don't fire too.
The same code works if I use a correct request from my own test applications with ORIGIN as follows;
http://172.16.100.2
This simulated request was issued from the same third party server to the listening Nancy server over the local network and without firewalls or virus scanners.
Any ideas?
Cheers
Dave

Getting the actual http request from HttpWebRequst Object in C#

I have a very simple app that sends an HttpWebRequest and gets a response. I need to know the exact request sent to the server. Is it possible?
Something like this:
POST /path/script.cgi HTTP/1.0
From: frog#jmarshall.com
User-Agent: HTTPTool/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 32
Build a basic web server with the System.Net.Sockets.TcpListener. The example shows how to do this. Then, point your HttpWebRequest to that server and see the results.

Categories

Resources