Call a webservice with out using proxy class

M

Madjid Nasiri

Hi,
I need call a webservice without using proxy class, How i can it?

Thanks for help
Madjid Nasiri
 
S

Scott Mitchell [MVP]

Madjid said:
I need call a webservice without using proxy class, How i can it?

Why do you need to do this? I guess, if nothing else, you could just
craft a properly formatted SOAP message and send it on over to the Web
service in an HTTP request, but why do all this heavy lifting? Proxy
classes are designed to simplify this whole process.

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
M

Madjid Nasiri

Hi Scott and other reader,
I have to write a program for call any webservice, this program must get
webservice's wsdl and show a xform for geting parameters and then send
parameter to webservice and show result.
How can send a SOAP message to a webservice? I wrote my program in asp.net
and C#.

Thanks for help, special scott.
 
S

Scott Mitchell [MVP]

Madjid said:
Hi Scott and other reader,
I have to write a program for call any webservice, this program must get
webservice's wsdl and show a xform for geting parameters and then send
parameter to webservice and show result.
How can send a SOAP message to a webservice? I wrote my program in asp.net
and C#.

So is the challenge, then, creating the form on the fly? That is, you
do not know the Web service's WSDL contract prior to when you want to
call it?


--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
D

DM McGowan II

This may help you get started. A great article from Roman Kiss on
CodeProject demonstrates programmatically reading WSDL and dynamically
generating in memory a proxy class that can be used to exercise methods. I
wrote a short snippet to test it below.

The key is the ServiceDescription class, at least, it's the starting point.

---------------- WebServiceAccessor.cs starts ----------------------------
Go to Roman's excellent article on The Code Project at:
http://www.thecodeproject.com/cs/webservices/webservicecallback.asp then
look for the code snippet titled WebServiceAccessor.
---------------- WebServiceAccessor.cs ends ------------------------------

---------------- ExeWSDL.cs starts ----------------------------
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Net;

namespace ExeWSDL
{
public class WSDLExecuter
{
public static void Main(string [] args)
{
WebServiceAccessor ac = new
WebServiceAccessor("http://www.mccomsoft.com/Test.asmx?wsdl");
object esObj = ac.CreateInstance("Test");
//string sProgramArguments = "";
object retval = ac.Invoke(esObj, "TestResponse", null);
Console.WriteLine((string) retval);
}
}
}
---------------- ExeWSDL.cs ends ------------------------------

Build with:

csc -out:ExeWSDL.exe ExeWSDL.cs WebServiceAccessor.cs

Dilton
 
M

Madjid Nasiri

Hi McGowan,

That's working. Very Thanks for answer

Mad Nas

DM McGowan II said:
This may help you get started. A great article from Roman Kiss on
CodeProject demonstrates programmatically reading WSDL and dynamically
generating in memory a proxy class that can be used to exercise methods. I
wrote a short snippet to test it below.

The key is the ServiceDescription class, at least, it's the starting point.

---------------- WebServiceAccessor.cs starts ----------------------------
Go to Roman's excellent article on The Code Project at:
http://www.thecodeproject.com/cs/webservices/webservicecallback.asp then
look for the code snippet titled WebServiceAccessor.
---------------- WebServiceAccessor.cs ends ------------------------------

---------------- ExeWSDL.cs starts ----------------------------
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Net;

namespace ExeWSDL
{
public class WSDLExecuter
{
public static void Main(string [] args)
{
WebServiceAccessor ac = new
WebServiceAccessor("http://www.mccomsoft.com/Test.asmx?wsdl");
object esObj = ac.CreateInstance("Test");
//string sProgramArguments = "";
object retval = ac.Invoke(esObj, "TestResponse", null);
Console.WriteLine((string) retval);
}
}
}
---------------- ExeWSDL.cs ends ------------------------------

Build with:

csc -out:ExeWSDL.exe ExeWSDL.cs WebServiceAccessor.cs

Dilton



Madjid Nasiri said:
Hi Scott and other reader,
I have to write a program for call any webservice, this program must get
webservice's wsdl and show a xform for geting parameters and then send
parameter to webservice and show result.
How can send a SOAP message to a webservice? I wrote my program in asp.net
and C#.

Thanks for help, special scott.
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top