help with non WDSL web service

  • Thread starter Thread starter MR
  • Start date Start date
M

MR

I apologize in advance for re-asking a question that I posed before. I understand a little more than i did before and I am posing 2 specific questions:

I need to write an application that sends orders to a non-Windows web service.

1) I received DTD files for the SOAP messages that I need to send. I was able to convert them to XSD files. Upon examination of the files it is apparent that the XSD does not match the database in any way. so the question is, assuming I have an ADO.NET recordset, what is the best way to build and format the XML message? Do i have to build the XML message element by element and field by field or is there a better way?

2) Unfortunately, this service does not have a WDSL document. In fact when I try to add a web reference to my c# application, i get the following result:

SOAP RPC Router : Sorry, I don't speak via HTTP GET- you have to use HTTP POST to talk to me.

what should be my next (or first) step in setting up the interface with this web service. i cannot use a web reference, so i assume i need to do a lot of hand coding here. where is the best place to start?

i appreciate any suggestions, references or links

thanks

m

PS I am using VS.2003 (would 2005 help in this case?)
 
MR,

1) I would use an XSLT styleshee here to transform your XML into the XML
that the web service requires. You can use the classes in the
System.Xml.Xsl namespace to perform these transformations.

2) If the service does not have a WDSL document, then I don't know if
there is much you can do. I would use the HttpWebRequest class to create a
request, and then set the content of the request to your XML (after setting
the headers appropriately of course). You mentioned that you can't add a
reference. Does the service offer a WSDL document that you can get through
other means? If so, you can use the WSDL.exe utility to generate the proxy
class which you can add to your project.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

P.S. There is nothing in VS.NET 2005 that would make this easier, btw.

I apologize in advance for re-asking a question that I posed before. I
understand a little more than i did before and I am posing 2 specific
questions:
I need to write an application that sends orders to a non-Windows web
service.
1) I received DTD files for the SOAP messages that I need to send. I was
able to convert them to XSD files. Upon examination of the files it is
apparent that the XSD does not match the database in any way. so the
question is, assuming I have an ADO.NET recordset, what is the best way to
build and format the XML message? Do i have to build the XML message element
by element and field by field or is there a better way?
2) Unfortunately, this service does not have a WDSL document. In fact when I
try to add a web reference to my c# application, i get the following result:
SOAP RPC Router : Sorry, I don't speak via HTTP GET- you have to use HTTP
POST to talk to me.
what should be my next (or first) step in setting up the interface with this
web service. i cannot use a web reference, so i assume i need to do a lot of
hand coding here. where is the best place to start?
i appreciate any suggestions, references or links
thanks
m
PS I am using VS.2003 (would 2005 help in this case?)
 
1) I received DTD files for the SOAP messages that I need to send. I
was able to convert them to XSD files. Upon examination of the files it
is apparent that the XSD does not match the database in any way. so the
question is, assuming I have an ADO.NET recordset, what is the best way
to build and format the XML message? Do i have to build the XML message
element by element and field by field or is there a better way?
You have to build it element by element. The easiest way is to ask the
Server party for an example. You can build a string like that on the fly
using StringBuilder.

After that you could verify your string against the DTD or XSD, but this
is not required.

When the string is done you send it to the webserver using the
HttpWebRequest class. I posted an example earlier, just ask if you would
like to see it posted again.
2) Unfortunately, this service does not have a WDSL document. In fact
when I try to add a web reference to my c# application, i get the
following result:

SOAP RPC Router : Sorry, I don't speak via HTTP GET- you have to use
HTTP POST to talk to me.

what should be my next (or first) step in setting up the interface with
this web service. i cannot use a web reference, so i assume i need to do
a lot of hand coding here. where is the best place to start?
Read the MSDN docs on HttpWebRequest. Read up on XSD and see if you can
create a SOAP message (it's just a string!) that conforms to the XSD/DTD.
See if you can ask the Server party for a working sample. They must have
a test client themselves, right? If you're desperate you can capture the
SOAP conversation using a tool like Ethereal. :)

Greetings,
Wessel
 
Wessel Troost said:
You have to build it element by element. The easiest way is to ask the
Server party for an example. You can build a string like that on the fly
using StringBuilder.

I wouldn't advise doing that. You'll probably get escaping rules and things
wrong. Use an XmlTextWriter at least.
 
I wouldn't advise doing that. You'll probably get escaping rules and
things
wrong. Use an XmlTextWriter at least.

Excuse my ignorance, but what do you mean with escaping rules?

Greetings,
Wessel
 
Wessel Troost said:
Excuse my ignorance, but what do you mean with escaping rules?

Greetings,
Wessel

When writing text encoded XML you have to escape reserved characters in the
data (typically '<','>', and'&'), though there are additional characters in
attribute values. XmlTextWriter will deal with all this for you.

If you are writing raw XML, you also need to make sure you understand the
XML encoding rules for all the different data types (e.g. dates,
booleans,..). Not that hard, but you can't just wing it without knowing
something about XML.

Nigel
 
Back
Top