469,964 Members | 1,714 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

Sending XML SOAP message directly to web service from 3rd party app.

I have a vb.net web service and client that are both working fine.
If someone wanted to consume our web service using .NET, no problem.
Im a little confused on how non .NET clients would use the web service
though.

Question 1: Does Java etc have some kind of SOAP tool kit developers
could use to access our web service?

Question 2: .NET conveniently shows what the serialized xml looks like
and what the web service expects (Please see below). If I somehow
posted this xml directly to the web service would my client receive a
valid response? I have tried this (to no avail) but am not sure if im
supposed to post the xml or send using some kind of stream writer?

What I would love to do is create a simple client form containing a
multiline text box, post the xml into text box (see below) then
somehow send the contents of the text box containing xml to the web
service and receive back a response. Im sure this must be simple
(guess im kind of avoiding the .net web service proxy) but am stuck.

Anybody got any links to some info which may help me please?

Example xml i would like to post directly to web service...

POST /api/Safenames_IDP_XML_API_WebService/Safenames_IDP_XML_API.asmx
HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1/IDP
DomainAvailabilityChecker(LoginKey as string, DomainNames as
DomainArrayClass)"

<?xml version="1.0" encoding="utf-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/">
<soap:Body>
<IDP_x0020_DomainAvailabilityChecker_x0028_LoginKe y_x0020_as_x0020_string_x002C__x0020_DomainNames_x 0020_as_x0020_DomainArrayClass_x0029_
xmlns="http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1">
<LoginKey>string</LoginKey>
<DomainNames>
<DomainArrayClass>
<DomainName>string</DomainName>
<Success>boolean</Success>
<CommandName>string</CommandName>
<Description>string</Description>
</DomainArrayClass>
<DomainArrayClass>
<DomainName>string</DomainName>
<Success>boolean</Success>
<CommandName>string</CommandName>
<Description>string</Description>
</DomainArrayClass>
</DomainNames>
</IDP_x0020_DomainAvailabilityChecker_x0028_LoginKey _x0020_as_x0020_string_x002C__x0020_DomainNames_x0 020_as_x0020_DomainArrayClass_x0029_>
</soap:Body>
</soap:Envelope>
Nov 21 '05 #1
2 15193
MJ
I am sure that there Java Toolkits but it's quite while since I have
programmed in Java :)

But, more helpfully, the code below takes the contents of a multiline
textbox control, txtMessageBody, and uses an System.Net.HttpWebRequest
object to send the SOAP Envelope to the specified ASMX file with the
specified SOAPAction header. It then saves the response to a
response.xml file which is then loaded in to a WebBroswer control,
browser. Thus displaying the response to the request on a Winform but
with full IE XML rendering features.

There are possibly better ways of doing this but it has worked for me
when I was in a hurry and needed to test by service.

HTH.

string messageBody = "";
byte[] messageBytes;
HttpWebRequest webRequest =
(HttpWebRequest)WebRequest.Create("http://localhost/api/Safenames_IDP_XML_API_WebService/Safenames_IDP_XML_API.asmx");
webRequest.ContentType = "text/xml; charset=utf-8";
webRequest.Headers.Add
"SOAPAction","http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1/IDPDomainAvailabilityChecker(LoginKey
as string, DomainNames as DomainArrayClass)");
webRequest.Method = "POST";

messageBody = "<?xml version="1.0"
encoding="utf-8"?><SOAP-ENV:Envelope
xmlns:SOAPENV='http://schemas.xmlsoap.org/soap/envelope/'><SOAP-ENV:Body>";

messageBody = txtMessageBody.Text;

messageBody += "</SOAP-ENV:Body></SOAP-ENV:Envelope>";
webRequest.ContentLength = messageBody.Length;
messageBytes = Encoding.ASCII.GetBytes(messageBody);
Stream requestStream = webRequest.GetRequestStream();
requestStream.Write(messageBytes,0,messageBytes.Le ngth);
HttpWebResponse webResponse =null;
Stream responseStream = null;

try
{
webResponse = (HttpWebResponse)webRequest.GetResponse();
responseStream = webResponse.GetResponseStream();
byte[] response = new byte[webResponse.ContentLength];
responseStream.Read(response,0,response.Length);
string file = "response.xml";
StreamWriter writer = new StreamWriter(file,false);
writer.Write(Encoding.ASCII.GetString(response));
writer.Close();
string path = Application.ExecutablePath;
path= path.Substring(0, path.IndexOf(Application.ProductName +
".exe"));
browser.Navigate(path + file);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
responseStream.Close();
if(webResponse != null)
{
webResponse.Close();
}
requestStream.Close();
}

pa*******@safenames.net (Paul Hale) wrote in message news:<6b**************************@posting.google. com>...
I have a vb.net web service and client that are both working fine.
If someone wanted to consume our web service using .NET, no problem.
Im a little confused on how non .NET clients would use the web service
though.

Question 1: Does Java etc have some kind of SOAP tool kit developers
could use to access our web service?

Question 2: .NET conveniently shows what the serialized xml looks like
and what the web service expects (Please see below). If I somehow
posted this xml directly to the web service would my client receive a
valid response? I have tried this (to no avail) but am not sure if im
supposed to post the xml or send using some kind of stream writer?

What I would love to do is create a simple client form containing a
multiline text box, post the xml into text box (see below) then
somehow send the contents of the text box containing xml to the web
service and receive back a response. Im sure this must be simple
(guess im kind of avoiding the .net web service proxy) but am stuck.

Anybody got any links to some info which may help me please?

Example xml i would like to post directly to web service...

POST /api/Safenames_IDP_XML_API_WebService/Safenames_IDP_XML_API.asmx
HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1/IDP
DomainAvailabilityChecker(LoginKey as string, DomainNames as
DomainArrayClass)"

<?xml version="1.0" encoding="utf-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/">
<soap:Body>
<IDP_x0020_DomainAvailabilityChecker_x0028_LoginKe y_x0020_as_x0020_string_x002C__x0020_DomainNames_x 0020_as_x0020_DomainArrayClass_x0029_
xmlns="http://tempuri.org/Safenames_IDP_XML_API_WebService/Service1">
<LoginKey>string</LoginKey>
<DomainNames>
<DomainArrayClass>
<DomainName>string</DomainName>
<Success>boolean</Success>
<CommandName>string</CommandName>
<Description>string</Description>
</DomainArrayClass>
<DomainArrayClass>
<DomainName>string</DomainName>
<Success>boolean</Success>
<CommandName>string</CommandName>
<Description>string</Description>
</DomainArrayClass>
</DomainNames>
</IDP_x0020_DomainAvailabilityChecker_x0028_LoginKey _x0020_as_x0020_string_x002C__x0020_DomainNames_x0 020_as_x0020_DomainArrayClass_x0029_>
</soap:Body>
</soap:Envelope>

Nov 21 '05 #2
Hi Paul,

Absolutely... but the quality of these Java tools vary wildly. The most
notoriously "pull your hair out" is called Glue. The best ones are from
Systinet, IBM (Websphere) and Bea.

On your question # 2, the automatic documentation page doesn't fully expand
members of complex types that are passed as arguments. As such, it's not
always possible to directly copy/paste. If you install a trace extension
into your web service (available on gotdotnet for free) and then use
trace.axd to monitor the packets as they are run, then you can see the
exact content of what was passed on the wire.
Here's an HTML test form I use to do simple testing such as you describe.

Good luck

Dan Rogers
Microsoft Corporation

---------
<HTML>
<SCRIPT LANGUAGE="VBScript">

sub postit(theform)
set xmlhttp = CreateObject("Msxml2.XMLHTTP")
url = "http://" + theform.serverName.value + "/"+ theform.dsmlURL.value
xmlhttp.open "POST", url,false
xmlhttp.setRequestHeader "SOAPAction", theform.soapAction.value
xmlhttp.setRequestHeader "Content-type", "text/xml"
theform.responseEl.value = ""
xmlhttp.send theform.requestEl.value
theform.responseEl.value = xmlhttp.responsetext
xmldoc.src = xmlhttp.responsexml

end sub
</SCRIPT>
<BODY>
<FORM target="_blank" name="myform" METHOD="post" ACTION="postit">
<FONT face="Arial"><FONT color="#000099"><FONT size="7">SOAP Test
Client</FONT><br>
</FONT></FONT>
<P><font face="Verdana" size="2"> Server Name&nbsp; <input type="text"
name="serverName" size="29" value="localhost" id="Text1">
&nbsp;&nbsp; Virtual Directory <input type="text" name="dsmlURL"
size="50" value="AddressService/AddressService.asmx">&nbsp;
<br>
<br>
SOAP Action&nbsp; <INPUT id="Text3" type="text" size="85"
value='GetTestAddress' name="soapAction"></font></P>
<P><FONT face="Verdana" size="2"><B>SOAP&nbsp;request:</B><font
color="#0000ff"> </font>
</FONT>
</P>
<p>
<TEXTAREA fontsize="large" vscroll="true" rows="10" cols="110"
name="requestEl" value="">
</TEXTAREA>
<p>
<INPUT TYPE="button" Value="Send Request" OnClick="postit(myform)">
<P>
<b><font face="Verdana" size="2">The&nbsp;SOAP response: </font></b>
<p>
<TEXTAREA rows="20" cols="110" name="responseEl" value="">
</TEXTAREA>
<br>
<XML id="xmldoc" src="" ></XML>
&nbsp;</FORM>
</P>
</BODY>
</HTML>
------- <snip>
Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mark | last post: by
3 posts views Thread by mark kurten | last post: by
reply views Thread by Cleo | last post: by
reply views Thread by jennifer.perkins | last post: by
4 posts views Thread by Jonathan [sbrodolo] | last post: by
31 posts views Thread by Bryan Dickerson | last post: by
1 post views Thread by Peter van der veen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.