Question Internal Server Error in API Call from Fiddler

Anonymous

Well-known member
Joined
Sep 29, 2020
Messages
84
Programming Experience
Beginner
Hello,

I found a list of public Soap APIs that can be used on this link


But most of the APIs are giving me internal server error when calling from fiddler.

For example, I used this API which returns the capital city of the country sent in the request body.


I passed the following in the header box -

Content-Type : text/xml

and the request body is of the following format -

<CapitalCity>
<sCountryISOCode>US</sCountryISOCode>
</CapitalCity>


1603276311881.png


Just wanted to know if I am calling them correctly or not ?
 
You're missing the soap Envelope/Body, follow the link for each service and look at the sample request message.

Not sure how useful this will be though, in C# you would add a service reference to the service description (WDSL) and use the generated proxy classes for interaction. The soap request messages would be generated, and the soap response messages would be translated automatically to the proxy types.
 
You're missing the soap Envelope/Body, follow the link for each service and look at the sample request message.

Not sure how useful this will be though, in C# you would add a service reference to the service description (WDSL) and use the generated proxy classes for interaction. The soap request messages would be generated, and the soap response messages would be translated automatically to the proxy types.
Thanks, it is working now. But I am extremely confused now. Actually, the API that I am referring to for learning( cannot post here due to confidentiality) is a SOAP API ( it has a WSDL) but I was able to run it in fiddler without the soap envelope. That API accepts request body in XML and also provides response in XML.

It's similar to this API ( that I practised for GET ) -


I simply accessed this API using HttpWebRequest class of C#. I did not add a service reference to the service description.

C#:
 private const string URL = "https://reqbin.com/echo/get/xml";
        public void FetchResults()
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
//request.Method = "GET";
            request.ContentType = " application/xml";
            WebResponse response = request.GetResponse();
            // Display the status.
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);

            // Get the stream containing content returned by the server.
            // The using block ensures the stream is automatically closed.
            Stream dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.

            StreamReader readerStream = new StreamReader(dataStream, System.Text.Encoding.GetEncoding("utf-8"));
 
                // Read the content.
                string responseFromServer = readerStream.ReadToEnd();
                // Display the content.
          
                Console.WriteLine(responseFromServer);

            XmlSerializer serializer = new XmlSerializer(typeof(Response));

            Response result = new Response();

            using (TextReader reader = new StringReader(responseFromServer))
            {
                result = (Response)serializer.Deserialize(reader);
            }

            //Console.WriteLine(name);

            Console.WriteLine("Finally we received " + result.ResponseMessage);

            

            response.Close();

        }

I used the following proxy class for interaction -

C#:
 /// <remarks/>
        [System.SerializableAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
        [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
        public partial class Response
        {

            private byte responseCodeField;

            private string responseMessageField;

            /// <remarks/>
            public byte ResponseCode
            {
                get
                {
                    return this.responseCodeField;
                }
                set
                {
                    this.responseCodeField = value;
                }
            }

            /// <remarks/>
            public string ResponseMessage
            {
                get
                {
                    return this.responseMessageField;
                }
                set
                {
                    this.responseMessageField = value;
                }
            }

      
    }



    }

Is it possible for an API to have a SOAP WSDL and have REST endpoint ? Is it also possible to a REST API to accept request body in XML and provide response also in XML?

I am sorry but I am extremely confused between these two now.
 
Is it possible for an API to have a SOAP WSDL and have REST endpoint ? Is it also possible to a REST API to accept request body in XML and provide response also in XML?
Yes to both questions.
 
An api having a wsdl and rest endpoints would be called a Rest Api and not a soap api, is this statement correct???
Actually this question arose because i had read somewhere that only soap apis can have wsdl. So, an api having both wsdl and rest endpoints got me confused if is a soap or a rest.
 
If you go the service page you'll see a manual invoke form, inspecting it with Fiddler shows this uses a slightly different url and request by form data, while returning plain xml (not SOAP). So a service can be configured for different kinds of requests and responses. Historically .Net web services have evolved from Asp.Net Web Service (SOAP) to WCF service (SOAP, REST) to Asp.Net Web API (REST).
 
Also interesting reading here about how to use WSDL 2.0 to describe a REST API:

Personally, despite the extra infrastructure needed for Swagger, I prefer Swagger over WSDL.
 
If you go the service page you'll see a manual invoke form, inspecting it with Fiddler shows this uses a slightly different url and request by form data, while returning plain xml (not SOAP). So a service can be configured for different kinds of requests and responses. Historically .Net web services have evolved from Asp.Net Web Service (SOAP) to WCF service (SOAP, REST) to Asp.Net Web API (REST).
Is there anyway I can call this API with simple XML request body( without soap envelope) and get a response in simple XML in fiddler ?
 
If you go the service page you'll see a manual invoke form, inspecting it with Fiddler shows this uses a slightly different url and request by form data, while returning plain xml (not SOAP). So a service can be configured for different kinds of requests and responses. Historically .Net web services have evolved from Asp.Net Web Service (SOAP) to WCF service (SOAP, REST) to Asp.Net Web API (REST).
Or is there any other API which I can get which uses a simple xml request body and returns response in plain xml ? The reason of me being persistently asking for this kind of api is that I have to create an application in future using this kind of api . There is an existing application from where I can refer the code but instead of copy pasting the code from the existing app , I want to develop a test application so that I should understand the very core concept and steps to hit the api and fetch response from it.

I have understood get but I am struggling with post as I have not been able to find any api of this format till now.
 
Is there anyway I can call this API with simple XML request body( without soap envelope) and get a response in simple XML in fiddler ?
You can see in Fiddler when you manually invoke the form how the request should look like.
 
You can see in Fiddler when you manually invoke the form how the request should look like.
I made the following changes in the header

Content-Type : application/xml
Accept: application/xml
Host: webservices.oorsprong.org
Content-Length: 79


but it is still giving me unsupported media type error
 
Is there anyway I can call this API with simple XML request body( without soap envelope) and get a response in simple XML in fiddler ?
If you want to use SOAP the answer is no, SOAP requires the envelope information. It's part of the SOAP standard protocol.

If you want to use REST, then find a REST API which accepts and returns XML. I believe that some of Microsoft's ODATA based web services accept and return XML or JSON.
 
Or is there any other API which I can get which uses a simple xml request body and returns response in plain xml ? The reason of me being persistently asking for this kind of api is that I have to create an application in future using this kind of api . There is an existing application from where I can refer the code but instead of copy pasting the code from the existing app , I want to develop a test application so that I should understand the very core concept and steps to hit the api and fetch response from it.
As I recall the Weatherunderground APIs does this. It accepts simple XML and returns simple XML as well. Unfortunately, Weatherunderground has stopped offering web services to the public and is now focused on enterprise customers.

Perhaps I'm missing something. Why don't you just create a simple ASP.NET Web API application that accepts and returns XML. The current version does content negotiation. If the requester wants data in XML, then it'll return the data as XML.
 
Back
Top Bottom