Manually calling a web service with a SOAP message

Pete

I'm trying to call a SOAP-based WCF web service by creating an HTTP request by hand. I need to do this because I'm trying to implement this in an environment that will have HTTP access, but not the WCF service client stuff. It will actually be implemented in a different language, but I'm trying to do a proof of concept in C# first.

The WCF service has a simple function that takes a string address and then returns a complex object with geocoding information about the address. Right now, I'm just looking for it to return a proper response as a string. As it is, it returns HTML describing the WSDL discovery, so the call isn't working.

I pulled the SOAP message from an actual functioning service call (I wrote some code to intercept and extract the SOAP message before it went out).

So the trick now is just getting the rest of the HTTP to work. So my code is as follows:

string soap = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
              "   <s:Header>" +
              "     <Action s:mustUnderstand=\"1\" xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">http://tempuri.org/IGeoCode/GetLocation</Action>" +
              "   </s:Header>" +
              "   <s:Body>" +
              "     <GetLocation xmlns=\"http://tempuri.org/\">" +
              "       <address>1600 Pennsylvania Ave NW, Washington, DC 20500</address>" +
              "     </GetLocation>" +
              "   </s:Body>" +
              " </s:Envelope>";

var obj = new XMLHTTP60();
obj.open("POST", @"http://MyServer:4444/GeoCode.svc");
obj.setRequestHeader("Content-Type", "text/xml");
obj.setRequestHeader("SOAPAction", "http://MyServer:4444/GeoCode.svc"); 
obj.setRequestHeader("Content-Length", soap.Length.ToString());
obj.send(soap);
string stat = obj.statusText;
string str = obj.responseText;
string resp = obj.getAllResponseHeaders();

What I expect back is something along the lines of:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
  <s:Body>
    <GetLocationResponse xmlns="http://tempuri.org/">
      <GetLocationResult xmlns:a="http://schemas.datacontract.org/2004/07/GeoCodeSvc" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        ...
          Lots of stuff here
        ...
      </GetLocationResult>
    </GetLocationResponse>
</s:Envelope>
  </s:Body>

Instead, I'm getting a 400 (Bad Request) status.

Jim

I think your problem is with the SOAPAction statement. You don't want to point that to your service. Instead, it should be whatever the WSDL calls the end point.

If you're feeling adventurous, the end point is typically one of the last entries in the WSDL. I can't recall the specific term they use, but it should be obvious.

HTH, Jim

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling a web service SOAP in java

From Dev

Compressing request and response soap message of wcf web service

From Dev

Compressing request and response soap message of wcf web service

From Dev

Creating and sending a SOAP message in java to a very simple web service

From Dev

Calling web service from Java "The message with Action '' cannot be processed at the receiver"

From Dev

Calling a SOAP service using REST service

From Dev

Calling a SOAP service using REST service

From Dev

.NET Web-service - To SOAP or not to SOAP

From Dev

Blackboard SOAP web service php

From Dev

Consuming a SOAP web service with Swift

From Dev

Securing a PHP Web service (SOAP)

From Dev

SOAP Web Service with Inno Setup

From Dev

SOAP API wsdl Service calling using perl

From Dev

calling a soap service from C#

From Dev

SOAP API wsdl Service calling using perl

From Dev

Calling a SOAP service with Python & zato.io

From Dev

Calling web service to web service; Architecture View

From Dev

In sending a soap message "manually" I get AddressingNone error with WCF

From Dev

Calling a web service using nodejs

From Dev

calling https web service methods

From Dev

Calling web service with ssl certificates

From Java

Connect an android application to SOAP web-service

From Dev

How to implement web service consumer SOAP with Mulesoft

From Java

How to call a SOAP web service on Android

From Dev

Spring Integration Web Service with SOAP and JSON

From Dev

Pass ArrayList data into SOAP web service in android

From Dev

SOAP web service unit/integration testing

From Dev

Consume SOAP based web service with https

From Dev

C# soap web service and Java client

Related Related

HotTag

Archive