Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

The remote server returned an unexpected response: (400) Bad Request./protocolexception was unhandled.

$
0
0

hi,

     I created a simple web service client to consume a method from this wsdl file(http://services.healthindicators.gov/v4/SOAP.svc?wsdl): but got an error: The remote server returned an unexpected response: (400) Bad Request.  Tried all setting in app config file, but still getting the same error.

Anybody please help me sort out this problem.

Thanks in advance.

code:

using System;
using System.Xml;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HIWTest.HiwServiceRef;

namespace HIWTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)
        {

               // create soap client 
            SOAPClient soap = new SOAPClient();

                Array result = soap.GetYears(1).ToArray(); ;
                System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(result.GetType());
                System.IO.StreamWriter rt = new System.IO.StreamWriter("e:\\year1.xml");
                xs.Serialize(rt, result);
                rt.Close();

        }
    }
}

app.config file :

<?xml version="1.0" encoding="utf-8"?>  <configuration><system.diagnostics><sources><source name="System.ServiceModel"
					  switchValue="Information, ActivityTracing"
					  propagateActivity="true"><listeners><add name="traceListener"
						 type="System.Diagnostics.XmlWriterTraceListener"
						 initializeData= "e:\Traces.svclog" /></listeners></source></sources></system.diagnostics><system.serviceModel><bindings><basicHttpBinding><binding name="SOAP" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:01:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="false"><readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /><security mode="None"><transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" /><message clientCredentialType="UserName" algorithmSuite="Default" /></security></binding></basicHttpBinding></bindings><client><endpoint address="http://services.healthindicators.gov/v4/SOAP.svc?wsdl"
                binding="basicHttpBinding" bindingConfiguration="SOAP" contract="HiwServiceRef.ISOAP"
                name="SOAP"  /></client></system.serviceModel></configuration>

please help!


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>