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);
Related
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...
I've followed Microsoft's Get started with EWS Managed API client applications tutorial, in an effort to build an application that will get specific items from a mailbox on an Exchange server.
It seems that after the initial auto-discover operations succeed, no matter what kind of request I send through the API, I get a response back containing the following:
HTTP/1.1 415 Cannot process the message because the content type 'text/plain; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.
With Microsoft.Exchange.WebServices.Data.ExchangeService.TraceEnabled = true, the trace of a typical request looks like this (this one is generated by calling Folder.Bind(service, "IT", propSet)):
<?xml version="1.0" encoding="utf-16"?>
<Trace Tag="EwsRequest" Tid="1" Time="2019-03-01 14:42:02Z" Version="15.0.913.15">
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body>
<m:GetFolder>
<m:FolderShape>
<t:BaseShape>IdOnly</t:BaseShape>
</m:FolderShape>
<m:FolderIds>
<t:FolderId Id="IT" />
</m:FolderIds>
</m:GetFolder>
</soap:Body>
</soap:Envelope>
</Trace>
It looks like the Content-Type header is missing altogether, so the server sees the request as text/plain; charset=utf-8. It shouldn't be a problem to add Content-Type: text/xml; charset=utf-8 to requests that the ExchangeService object makes, but the member Dictionary HttpHeaders is not settable (see the interface in ExchangeServiceBase).
Any idea how I can either send the server an acceptable request with the EWS Managed API, or configure the target Exchange server so that it accepts the requests I'm sending? I've come across lots of related SO questions, but none with an actual answer to this problem.
I was getting the same error and the only clue I could find was this thread.
I eventually fixed it by switching to Microsoft.Exchange.WebServices.NETStandard -v 1.1.3 (from -v 2.0.0-beta1).
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!
I'm working on an old web site. It is calling an ASP.Net web service (old .asmx files). Whenever an exception happens in the web service, it will throw a SoapException. The client catches this exception but is not able to pars it.
I'm viewing the SOAP request and response using both Fiddler and SOAP UI and reading this article http://msdn.microsoft.com/en-us/library/aa480514.aspx I expect to get the response in the following format:
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Server was unable to process request. Something bad happened</faultstring>
<detail />
However, I'm just getting the following response:
HTTP/1.1 500 Internal Server Error
Server: ASP.NET Development Server/10.0.0.0
Date: Thu, 12 Jun 2014 05:27:14 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 164
Connection: Close
System.Web.Services.Protocols.SoapException: Something bad happened
at WebService1.Service1.HelloWorld() in ...
Which I believe is the reason the client can't process the exception.
This happens even in a sample Hello World web service.
What can be wrong?
UPDATE: When I call my web service method that does NOT throw exception, I will get response in the following format:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ords="http://mydomain.com/">
<soapenv:Header/>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
This is how I throw the SoapException:
[WebMethod]
public string HelloWorld()
{
throw new SoapException("Something bad happened", SoapException.ClientFaultCode);
//return "Hello World";
}
I found some httpHandlers and modules in the web service web.config files that were not used at all. Removing those fixed the problem and now I'm getting the correct XML SOAP fault in the response.
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.