473,651 Members | 3,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

accessing webservice with soap

Plater
7,872 Recognized Expert Expert
I have a webservice that claims the following:

SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
Expand|Select|Wrap|Line Numbers
  1. POST /testdb/UnitReporting.asmx HTTP/1.1
  2. Host: localhost
  3. Content-Type: text/xml; charset=utf-8
  4. Content-Length: length
  5. SOAPAction: "http://mylocation/UpdateInformation"
  6.  
  7. <?xml version="1.0" encoding="utf-8"?>
  8. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  9.   <soap:Body>
  10.     <UpdateInformation xmlns="http://mylocation/">
  11.       <WhenSent>dateTime</WhenSent>
  12.       <StatusMessage>string</StatusMessage>
  13.     </UpdateInformation>
  14.   </soap:Body>
  15. </soap:Envelope>
  16.  
Now I tried to produce this using HttpWebRequest and sent the following(pulle d from a packet watcher):
Expand|Select|Wrap|Line Numbers
  1. POST /testdb/UnitReporting.asmx/UpdateInformation HTTP/1.1
  2. Content-Type: text/xml; charset=utf-8
  3. SOAPAction: http://mylocation/UpdateInformation
  4. Content-Length: 450
  5. Host: localhost
  6.  
  7. <?xml version="1.0" encoding="utf-8"?>
  8. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  9.   <soap:Body>
  10.     <UpdateInformation xmlns="http://mylocation/">
  11.       <WhenSent>12/30/2008 3:28:01 PM</WhenSent>
  12.       <StatusMessage>Nothing to report</StatusMessage>
  13.     </UpdateInformation>
  14.   </soap:Body>
  15. </soap:Envelope>
  16.  
For return result:
Expand|Select|Wrap|Line Numbers
  1. HTTP/1.1 500 Internal Server Error
  2. Server: Microsoft-IIS/5.1
  3. Date: Tue, 30 Dec 2008 20:28:02 GMT
  4. X-Powered-By: ASP.NET
  5. X-AspNet-Version: 2.0.50727
  6. Cache-Control: private
  7. Content-Type: text/plain; charset=utf-8
  8. Content-Length: 236
  9.  
  10. System.InvalidOperationException: Request format is invalid: text/xml; charset=utf-8.
  11.    at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
  12.    at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
  13.  

If I use a regular old POST urlencoded style, i am able to execute the function fine, but trying to do soap fails saying the contenttype is wrong?

Any ideas?



Edit: The (correct version) code I use to produce this:
Expand|Select|Wrap|Line Numbers
  1. private static bool DoSoap11Style()
  2. {
  3.     bool retval = false;
  4.     try
  5.     {
  6.         string test = "http://localhost/testdb/UnitReporting.asmx/UpdateInformation";
  7.         HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(test);
  8.         hwr.Method = "POST";
  9.         hwr.ContentType = "text/xml; charset=utf-8";
  10.         hwr.Headers.Add("SOAPAction", "http://mylocation/UpdateInformation");
  11.  
  12.         string postData = GetPostDataSoap11();
  13.         byte[] byte1 = Encoding.UTF8.GetBytes(postData.ToString());
  14.         hwr.ContentLength = byte1.Length;
  15.         Stream newStream = hwr.GetRequestStream();
  16.         newStream.Write(byte1, 0, byte1.Length);
  17.         newStream.Close();
  18.  
  19.         HttpWebResponse hresp = (HttpWebResponse)hwr.GetResponse();
  20.     }
  21.     catch (Exception ee)
  22.     {
  23.         bool ignoreme = (ee.Message == "");
  24.         retval = false;
  25.     }
  26.     return retval;
  27. }
  28.  
  29. private static string GetPostDataSoap11()
  30. {
  31.     StringBuilder postData = new StringBuilder("");// "firstone=" + "";
  32.     postData.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
  33.     postData.Append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n");
  34.     postData.Append("  <soap:Body>\r\n");
  35.     postData.Append("    <UpdateInformation xmlns=\"http://mylocation/\">\r\n");
  36.     postData.AppendFormat(null, "      <WhenSent>{0}</WhenSent>\r\n", DateTime.Now);
  37.     postData.AppendFormat(null, "      <StatusMessage>{0}</StatusMessage>\r\n", "Nothing to report");
  38.     postData.Append("    </UpdateInformation>\r\n");
  39.     postData.Append("  </soap:Body>\r\n");
  40.     postData.Append("</soap:Envelope>\r\n");
  41.  
  42.     return postData.ToString();
  43. }
Dec 30 '08 #1
1 5960
Plater
7,872 Recognized Expert Expert
And in typical fashion, the problem turned out to be the one thing I thought for sure was right:
http://localhost/testdb/UnitReporting.a smx/UpdateInformati on
is used for regular POST, while
http://localhost/testdb/UnitReporting.a smx
is used for soap connections.

REDIT: I guess I had read something wrong, the best working format I have found for soap requests is this:
string datetimeformat = @"yyyy-MM-ddTHH:mm:ss"

Everything else results in the original "local" time transfered to be normalized to the server's local timezone
Dec 30 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2319
by: Hans Kesting | last post by:
Hi, I'm trying to create a client for some webservice. BUT I have only limited information: * no WSDL available ("expected Q1-06") (it seems to be written in Java) * I don't have access (yet) to the real webservice * I *do* have example SOAP messages What I'm trying to do is to build a dummy webservice, which should accept (and respond with) the same SOAP messages. Then I can build my code
1
1354
by: Jinashe | last post by:
what do i need to enable accessing of webservices from a clients PC i'm hosting some webservices from my server in VB.NET. i've got some client windows applications done in VB.NET. what have i got to install on the clients PC to be able to access these webservices?? Will just the .NET Framework suffice??? Or do i have to install SOAP?? note - the OS of the client can be win98, win2K, win3000, winXP
7
5393
by: stephan querengaesser | last post by:
hi ng, i try to invoke a webservice-method with an filter-object, that contains value types. if i don´t want to filter the return value of the method, i have to pass a new instance of the filter-object without setting any properties. but the value type-properties can´t be null and the filter is set to 0 (int) or false (bool). therefore i did implement the propertySpecified-pattern like this:
7
4977
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type Parameter. I can call the first Method without Problems, the Parameter can be deserialized by the WebService. But if I want to call the second Method and give it an Array of Parameters, then the following exception is thrown by the WebService:...
7
2917
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure out to create a "DataSet" as the return type from the webservice?
4
6105
by: Kaush | last post by:
Hi all, I am creating a webservice to accept SOAP messages, parse the message and send a SOAP response back to the client accessing my web service using WSE-2 in ASP.NET. I am creating a class which derives from "SoapReceiver" class and do the processing here. To register this class by using the HTTP protocol, I am editing the "web.config" file. I am adding an "add" element to this config file as follows: <httpHandlers>
1
4031
by: jens Jensen | last post by:
Hello , i'm calling a webservice generated with oracle webservice java tools. I'm not able to add a web reference to a .net client the usual way with visual studio 2005. I was therefore provided with a set of Dll that implement the proxy needed to consume this web service. I'm now wrapping these dlls in a .Net webservice that can be consumed with Visual studio the familliar way.
0
1315
by: rakeshkumawat | last post by:
I am facing a problem while reading the result which is loaded in DOMDocument. In which I am sending a request to web service and getting a record of Single Order. This is my VB Code which is i am using.... ........................ Dim Connector As SoapConnector30 ' To connect to webservice Dim Serializer As SoapSerializer30 ' To serialize the XML data Dim Reader As SoapReader30 ' To read the Webservice...
5
2748
by: VictorG | last post by:
Hello, I am trying to secure a webservice using WSE 3.0 and the turnkey usernameForCertificateSecurity profile. I am passing a valid username token, and on the server I have overridden the Authenticate token call and it is being called. My ASP.NET service has a Login() method and it is being called during client application startup. Both the client and service have matching policy config files. Once authentication
0
8361
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8584
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.