Web service that is able to receive a xml "POST" and process it

J

Jay

Hello all,

I was wondering if someone can point me to a tutorial that show me how
I can set up a web service that can listen for me to send a POST from a
client? like so

Client sends http POST to http://www.mysite.com/processTheRequest. The
data being sent across is XML like so "<request><data>alot of text data
that I will manipulate and save to the sql database</data></request>"


the serverside should have some function to receive this data.

receiveData(object sender, events e)
{
manipulate the data and respond to the post with
"<response>success</response>"
}
 
S

S. Justin Gengo [MCP]

Jay,

That's what a webservice does by default. Just create the webservice method
and have it accept an xml parameter. XML is easily converted to and from a
dataset which is safe for sending in a webservice (data must be
serializable). In .NET 2.0 DataTables are also serializable. So you could do
something like this:

<WebMethod()> _
Public Sub XMLAcceptor(ByVal xmlDataset As Data.DataSet)

End Sub

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

Jay

what if I wanted to send xmldata as a string (that is formated in xml),
receive this string and do a

xmlDocument.Load(xmldata);


any examples or step by step tutorials?
 
S

S. Justin Gengo [MCP]

Jay,

You may certainly send the xml as a string just use ByVal xmlString As
String instead of the dataset.

Then load the string into an xml document like this:

xmldoc.LoadXml(sXML)

After that there are plenty of examples like this (do a google search on
"asp.net xmldoc" to see plenty more):

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=213

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

Jay

so I get to the point where I created a web service and it comes up to
this page when I push play. I can also click on jaytest and it will
take me to an invoke page... but when I try to send a transaction from
another application(that I have sent thousands of WebRequest Post to
our linux jboss server) it does not work.

---
The following operations are supported. For a formal definition, please
review the Service Description.

JayTest

HelloWorld
----------

SERVICE DECRIPTION CONTENT
-----------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.jaystest.com"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://www.jaystest.com"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified"
targetNamespace="http://www.jaystest.com">
- <s:element name="HelloWorld">
<s:complexType />
</s:element>
- <s:element name="HelloWorldResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="JayTest">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="strMyName"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="JayTestResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="JayTestResult"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
- <wsdl:message name="HelloWorldSoapIn">
<wsdl:part name="parameters" element="tns:HelloWorld" />
</wsdl:message>
- <wsdl:message name="HelloWorldSoapOut">
<wsdl:part name="parameters" element="tns:HelloWorldResponse" />
</wsdl:message>
- <wsdl:message name="JayTestSoapIn">
<wsdl:part name="parameters" element="tns:JayTest" />
</wsdl:message>
- <wsdl:message name="JayTestSoapOut">
<wsdl:part name="parameters" element="tns:JayTestResponse" />
</wsdl:message>
- <wsdl:portType name="Service1Soap">
- <wsdl:eek:peration name="HelloWorld">
<wsdl:input message="tns:HelloWorldSoapIn" />
<wsdl:eek:utput message="tns:HelloWorldSoapOut" />
</wsdl:eek:peration>
- <wsdl:eek:peration name="JayTest">
<wsdl:input message="tns:JayTestSoapIn" />
<wsdl:eek:utput message="tns:JayTestSoapOut" />
</wsdl:eek:peration>
</wsdl:portType>
- <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
- <wsdl:eek:peration name="HelloWorld">
<soap:eek:peration soapAction="http://www.jaystest.com/HelloWorld"
style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:eek:utput>
<soap:body use="literal" />
</wsdl:eek:utput>
</wsdl:eek:peration>
- <wsdl:eek:peration name="JayTest">
<soap:eek:peration soapAction="http://www.jaystest.com/JayTest"
style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:eek:utput>
<soap:body use="literal" />
</wsdl:eek:utput>
</wsdl:eek:peration>
</wsdl:binding>
- <wsdl:service name="Service1">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
- <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
<soap:address
location="http://localhost/WebServiceTest/Service1.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
-----------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top