Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1594
  • Last Modified:

Get values parameters from WSDL file

Hello Folks:

I need to get values from a WSDL file.
I've a site project in visual studio and I added a CRM web services like a Web Reference.

I dont know how to get values/parameters in C#.
My idea is in C# create a call to that web service.

I need an example or link to see how to do it.

thank you
0
nkoriginal
Asked:
nkoriginal
  • 8
  • 7
1 Solution
 
JenniQCommented:
Getting Started With .NET Web Services

There are two technologies in current use for creating and consuming web services in .NET. These are the ASMX or XML Web Services, and Windows Communication Foundation, or WCF.
 
A good starting point for ASMX web services is Using ASP.NET Web Services. Specifically, see Web References in Visual Studio and How to: Add and Remove Web References.

Now, the ASMX web service technology is the older techology from Microsoft. The new way to do web services in .NET is WCF. There's an excellent portal to WCF at http://msdn.microsoft.com/wcf. In particular, see Windows Communication Foundation, Conceptual Overview, and Getting Started Tutorial.

There are a few other Microsoft web service technologies I will mention only to warn you away from. They are obsolete and should not be used for new development. In fact, anyone using the following technologies should migrate to WCF as soon as possible.

Web Service Enhancements, or WSE were a set of stopgap releases that added to the ASMX technology to permit developers to work with the emerging WS-* standards as they were being developed by the industry. That means you will often find WSE mentioned in conjunction with security. This does not mean that WSE is the solution to security in web services, it means that WSE was that solution until WCF was released. WCF supersedes WSE, which is now obsolete.

Even more obsolete is the SOAP Toolkit. This was a way to create clients for web services, and worked for old VB or ASP applications. Do not use it.
0
 
nkoriginalAuthor Commented:
yes, you right.
I reading about that, like you said., the WSDL is an old technology.
but in the company i working, they' using that technology, and I need to work with that.
that's the reason I need a code or an example, to get values/parameters from a Web Reference WSDL.

I added that web services to my project but i dont have any idea how to work in C# to get the values.

thanks for your help
0
 
JenniQCommented:
OK so are you talking about the query string parameters sent to the WDSL? What extension is the web service ur trying to hit / grab data from?

Are you trying to read the return values from the web service? Consume, expose, or edit?

-- jq
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JenniQCommented:
Consumers of a Web Service need to know what the service offersfor example, what its Web callable method look like. Therefore, all Web Services optionally share another common XML document: a contract (note, Web Services built with ASP.NET always have a contract provided automatically).

If you hit the WS (it should be an ASMX or something) then it will show you the parameters it exposes.

If you see XML, then this web service returns XML.

Tools can use this XML schema to build proxy classes for ur Web Service. A proxy class is a class that looks and feels like a local object, but it is in fact doing the work to serialize, send, receive, and de-serialize our method request to a SOAP endpoint.

SOAP is prolly the route you wanna go. Let me know more and i can give u a code sample.

- jq
0
 
nkoriginalAuthor Commented:
I added the file webservice.wsdl. that's the file name.
Is a web services from CRM Sage application.

Right now I've that file in my project but I dont know how to interact with that file from C# file.
I need to setup the values (I will get them from the manual) and then return the values.

thanks again for your help
0
 
JenniQCommented:
1. Open the Solution Explorer in my project.
2. Right click on it and choose "add web reference"
3. A pop window appears.
4. In URL box, instead of type the web site address, enter the exact location of your wsdl file. The file, not path and don't forget to type the extension.
5. Click on "Go"
6. If everything's all right Visual Studio will recognize the wsdl and procedures inside.
7. All you have to do now is just label it to whatever you want.
8. Click "Add Reference"
9. Back to Solution Explorer window, you should see the wsdl file appears under WebReference node. You can now consume it in the same way as any other reference file.

Yeah, use the "MyWSDL test = New MyWSDL();" in C#.
0
 
nkoriginalAuthor Commented:
Jenni, thanks so much for your help. Is really good to start.
I will try it.

one more question, do you know how to get a value from that web service??
i found something like this, but Im a little confusing

If I put this:

String strCompanyID = Request.QueryString.Get("key1");
queryentityresult CompanyQueryResult = myCRM.queryentity(int.Parse(strCompanyID), "Company");
ewarebase CRMBase;
CRMBase = CompanyQueryResult.records;
company myCompanyRecord = (company)CRMBase;

I will get the companyID value, right?
but I dont understand how this code interact with the web service.
maybe Im so tired.

Sorry for this dumb question.
Thanks
myCRM.SessionHeaderValue = new SessionHeader();
myCRM.SessionHeaderValue.sessionId = Request.QueryString.Get("SID");
getversionstringresult CRMVersion = myCRM.getversionstring();
//Response.Write(CRMVersion.versionstring);
 
String strCompanyID = Request.QueryString.Get("key1");
queryentityresult CompanyQueryResult = myCRM.queryentity(int.Parse(strCompanyID), "Company");
ewarebase CRMBase;
CRMBase = CompanyQueryResult.records;
company myCompanyRecord = (company)CRMBase;
 
CompanyNameData.Text = myCompanyRecord.name;
COMPSLADATA.Text = myCompanyRecord.slaid;
CompWebSiteData.Text = myCompanyRecord.website;
CompTypeData.Text = myCompanyRecord.type; 

Open in new window

0
 
JenniQCommented:
Haha that is confusing.

Try:

Response.Write(Request.QueryString["key1"]);

So are you trying to get a parameter out of the webserivce ONCE SOMEONE HITS IT?

Consuming it... the webservce woudl not be in ur project.

So you must want to get the parameters inside the web service? Can you open the webservice and edit the code? If so, then in the WSDL file (or asmx) you add logic to get parameters.

Let me know which path ur taking.


0
 
nkoriginalAuthor Commented:
the web service is from external application.
when I added the web reference, I put the link to that web service, like this:
http://www.myserver.com/app/ws/webservices.wdsl
So that web reference is in my project.
My idea is to get values from that webservice, because the external application works with SQL DB and I need to get colums and values from that columns.
So i need to setup the parameters and then get the values.

I dont know if I explanied good or not, my english is not so good.

thanks
0
 
JenniQCommented:
OK got it,.

So add the WSDL as a reference in ur project, then create a new OBJECT with that Type.

Then you can get to all the parameters as properties. So if you named your reference "WorldTime" then this is how you'd "Consume" it:

        //Create instace of the WorldTime.dll
        WorldTime Time= new WorldTime();

        //get input from user
        Console.Write("Enter City: ");
        string City=Console.ReadLine();

        //gets date and time
        string DateTime=Time.GetTime(City);

        //write the citys time and date
        Console.WriteLine(DateTime);

Cuz WorldTime WSDL exposes those properties.

Does that make sense?
0
 
JenniQCommented:
Here is the PERFECT link for you my friend!

http://articles.techrepublic.com.com/5100-10878_11-5768122.html

-- jq
0
 
nkoriginalAuthor Commented:
Genius!
You make a really good explanation, and Im really more clear in what I need to do.
Thank you so much JenniQ.

The last comment clarify how the web service works and how to get the data. With that information  I can start.

thank again!!!
:D:D:D
0
 
nkoriginalAuthor Commented:
Really good answer. Excellent explanation to my question. Clear and easy solution. Thanks
0
 
JenniQCommented:
ha ha! I'm soo glad I could help.

Now go get some rest.
0
 
nkoriginalAuthor Commented:
JenniQ, If I open another question you can help?
Is not relative to this problem, is something I want to know..(create an stored procedure to insert automatically information in the SQL DB?).
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now