Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

Get response from Soap request

I have a simple page (SOAP Request) I can call in  a browser or from SoapUI.org app

http://mywcfClient.com/Service.asmx?op=SendMail

I type in the two variables and it returns a success or fail string

How do I call that in a C# Web Page?
Avatar of ste5an
ste5an
Flag of Germany image

hmm, doesn't look like a typical SOAP URI..

What does calling in "Web Page" mean? Consuming it on the client or server side? If it's server-side, than just add a service reference to your project.
Avatar of Larry Brister

ASKER

(Domain Name protected...)
http://mywcfClient.com/Service.asmx
Clicking on the SendMail Method brings that link above

Feed in parameters...
Returns string with no problems

I added the service reference in my Web Site

--- INside  a public string....

NO red underlines...

using (EWSendGridService.ServiceSoapClient client = new EWSendGridService.ServiceSoapClient())
{
    string svc = client.SendMail("myusernamer","mypassword");
    return svc;
}

On the exception I get this

The content type text/plain; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 53 bytes of the response were: 'Request format is invalid: text/xml; charset=utf-8. '.
If I use SoapUI from SoapUI.org... I get results no problem from Soap or Soap2
User generated image
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
kaufmed,
Tried that.

Same response... bad request
But this is the interesting thing
If I bring up that wcf directly in my chrome browser locally and ente the paramaters and execute
It returns the proper response

Locally if I execute through SoapUI... again... proper response...

On my live server
If I enter the url in chrome same thing... proper response

If I enter it in live Server Internet explorer OR try and run from code side however... "Bad Request"
I went another direction

Used something similar to this process...

            WebRequest request = WebRequest.Create("http://api.openweathermap.org/data/2.5/forecast?lat=25.804453&lon=-80.199015&units=Imperial&APPID=cc64ba34ec4b92a98b753cd0e22eb5d0" + "");
            WebResponse response = request.GetResponse();
            Stream data = response.GetResponseStream();
            string str = String.Empty;
            using (StreamReader sr = new StreamReader(data))
            {
                str = sr.ReadToEnd();
            }

Open in new window


Then handled the JSonData with NewtonSoft
JSON?? SOAP returns only XML..
ste5an
That's why I said I went another direction.
Terribly sorry for the late get back guys
Was out of country traveling.

This answer worked on the original question