WebService - XML

A

author

How do I change my webservice (ws.asmx.vb), so it can "understand"
when I send the below soap-xml to it ??

If I submit a normal html-form with input a+b, it works well. I know
how to send the soap-xml, but not how to get the webservice to work
with it.

TIA


<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="abcdefg">
<a>10</a>
<b>20</b>
</Add>
</soap:Body>
</soap:Envelope>


ws.asmx.vb
--
Imports System.Web.Services

<WebService(Namespace:="http://tempuri.org")> _
Public Class Service1
Inherits WebService

<WebMethod()> _
Public Function Add(ByVal a As Integer, ByVal b As Integer) As
Integer
Return a + b
End Function
--
 
C

Curt_C [MVP]

author said:
How do I change my webservice (ws.asmx.vb), so it can "understand"
when I send the below soap-xml to it ??

If I submit a normal html-form with input a+b, it works well. I know
how to send the soap-xml, but not how to get the webservice to work
with it.

TIA


<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="abcdefg">
<a>10</a>
<b>20</b>
</Add>
</soap:Body>
</soap:Envelope>


ws.asmx.vb
--
Imports System.Web.Services

<WebService(Namespace:="http://tempuri.org")> _
Public Class Service1
Inherits WebService

<WebMethod()> _
Public Function Add(ByVal a As Integer, ByVal b As Integer) As
Integer
Return a + b
End Function
You dont call ws.asmx.vb, you call ws.asmx
The .vb is the pre-compiled code.
 
J

John Timney \(ASP.NET MVP\)

Well its been a while since I did any soap! I think you might be looking for
the wrong thing.

I dont recall that you need to construct an actual soap envelope using xml
in asp.net as you would in asp for example. If I remember correctly, when
you set the proxy to the remote web service via the wsdl and have already
disabled get and post in the web.config for the web service - by default it
will use SOAP packaging to construct the request. You dont have to send the
XML envelope constructed as you are, just call the methods in the remote web
service through the proxy as you would call local methods and the package
will be constructed for you, delivered and the response returned.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
A

author

I think you might be looking for the wrong thing.
I dont recall that you need to construct an actual soap envelope

Some external application, without my control is sending soap-xml, so
it have to been in that way.
 
J

John Timney \(ASP.NET MVP\)

It looks then that the external application might not be sending enough
information to make your webservice tick - have you disabled get and post
yet in your webservice config to see if it accepts the envelope?

Here is an example of a full xml soap envelope destned for a .NET
webservice, for a simple hello world example.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle=
"http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Header>
<MyHeader xmlns="http://www.alfredbr.com/">
<MyName xsi:type="xsd:string">Alfred</MyName>
</MyHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<namesp1:HelloWorld2 xmlns:namesp1="http://www.alfredbr.com/"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Its quite different to that which you are recieving - you might therefore
have to modify your service, or get them to modify their request. From your
example, your a and b types are not defined so the webservice might simply
reject them as not being wsdl 1.1 compliant.

There is a utility at http://www.gotdotnet.com/team/tools/web_svc/ that
allows you to create and debug soap traffic to see why yours wont work.
I've not tried it, but it requires no code from what I gather, so its
probably a great test utility to work out where your problem is.

As I said, I've not done any soap request from none .NET clients for quite
some time so I dont have an easy answer for you, I hope that helps anyway.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
A

author

Well.. I'm confused, I don't know what is up and down ;)

Right now I just try to show the xml (the one you gave me) after
submit to the service, but I get "The remote server returned an error:
(500) Internal Server Error" all the time.

If I hit the asmx-file direct in a browser I get the webinterface. If
I submit the xml there, it seems to work fine.

So maybe it's my submit of soap-xml who don't work. But I use the same
method, as I do with other external application where I submit
soap-xml, and that works fine.


ws.asmx.vb
--
Imports System.Web.Services
Imports System.IO
Imports System.Xml

<WebService(Namespace:="http://tempuri.org")> _
Public Class Service1
Inherits WebService

<WebMethod()> _
Public Function test(ByVal strxml As String)
Dim reader
reader = New XmlTextReader(New StringReader(strxml))

Return strxml
End Function
End Class
--
 

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

Top