I know this is related to web services, but I don't want to write any more theoretical stuff. I just want to use an example to practice it. I hope you will do the same. Article It will help you.
The example includes all the web service processes. I plan to do this:
1. Create an ASP + Web Service
2. Complete the. asmx file and test it in the browser.
3. Create a customer for this web service.
4. The customer obtains the service
The problem I encountered was that in step 1, the client never got the Web service location, even though they were on the same machine but did not know each other. Then I use. Net. Almost all process zip packages are available, and I would like to give it a try. netProgramIn this regard, VS is also very good.
In the zip package, webserviceall.zip contains the entire project file andCode.
But it is best to install vs. Net beta 2. At least you need to install framework SDK beta 2.
Specifically:
1. in. create an ASP Web Service Project, and then. the asmx class implements your function, that is, service. I have written two simple functions: the helloworld function returns a "helloworld" string. The other is the sum of two numbers returned by an add operation. Set it to the hosts page, F5. If there is no error, ie should be started automatically. There is no difference from common syntax. The only difference is to add a webmethod mark before the function.
VB: Public Function add (A as integer, B as integer) as integer: Add = a + B; end functi
C #: [webmethod] public void int add (int A, int B) {return a + B ;}
Vs. Net will help you generate a. asmx. VB file and put it in your code. If it is manual, you can directly write it in. asmx.
2. you can see a very formatted page showing your two functions (or services). You can even execute them, for example, check the output "helloword" and make a 3 + 2 result to get 5 results, so that the Web Service is successfully established.
3. You need to create a web service customer so that it can get the "helloword" and add results for the services you provide. All you need to generate an SDL file. Similar to IDL, IDL compilation forms a Type Library so that VB can be pre-bound during development, And Then VB, intelligent help can be displayed in the Interdev development environment.
There are three ways to generate the file: manually write the file, and use the DOTNET tool, which is generated by the. asmx file. The automatically generated file can be used for viewing and testing and cannot be saved. To save the file, you need to use the framework SDK tool disco.exe, which runs in c: \ Program Files \ Microsoft. in the net \ frameworksdk \ bin directory, try http: // localhost/webservice1/service1.asmx first in IE? WSDL. If an XML file is successfully displayed in IE, this is an automatic method. Then, at the DOS prompt, run disco http: // localhost/webservice1/service1.asmx? WSDL indicates that you want to keep the file. After successful execution, you can see the. WSDL file.
4. Then, some of them are similar to Java and VB, which is easy to understand. That is, you need to generate a proxy class and then call the methods in this class on the client, that is, services. In this case, you need to use wsdl.exe, another tool in the framework SDK, to generate a. cs. VB or. js file, compile this file to generate a DLL, which is the so-called proxy class. Then you can call the helloworld and add functions in DOTNET web pages, Gui forms, web forms, or console programs to complete the process. Specific statement:
WSDL/out: mywebservice1.cs http: // localhost/webservice1/service1.asmx
You can see the CS file generated successfully.
5. Compile the class
CSC/out: mywebservice1.dll/T: Library/R: system. xml. dll/R: system. Web. Services. dll mywebservice1.cs
If the DLL is generated successfully, a presentation layer will call the service now. I manually drag it on this presentation layer. I think the. wsdl I generated is not used, that is, the service cannot be found.
4. 5 I did it manually and didn't want to build another project to compile mywebservice1.cs. DOTNET has a benefit. The component is automatically registered only after compilation, and does not need to use regsvr32 like Com. Currently, the COM component and DOTNET component are completely different, that is to say, you will be disappointed in VB reference and oleview, and you will not be able to see this DOTNET component.
6. Then you can call this component in your application. The application is very simple and is generally:
Dim OBJ as new service1
Dim retstr as string
Dim retintval as string
Retstr = obj. helloworld ()
Retintval = obj. Add (300,500)
In this way, it seems that DOTNET is very interesting, at least to show you a different thing, I think the heroes who have used com or COM + can easily think of this remote or Internet-like Com. In the past, COM had a fatal weakness and could not penetrate the firewall, now, this method is not only flexible, but also more standard. It encapsulates and hides soap and other network protocols at the underlying layer, and uses XML to transmit data and information. You only need to focus on the service function.
Think about Sina's news service. If there is such a web service interface, there is only a few simple words on the website for news display. The same stock site can provide you with stock information, travel airlines provide travel and flight information. There are too many interfaces and updates from time to time. I think there will be a web service interface or portal website in the future, and it will become a well-known portal like Yahoo.
Some resources:
Framework SDK beta 2
Http://download.microsoft.com/download/VisualStudioNET/Trial/2.0/W982KMeXP/EN-US/setup.exe
Microsoft ASP. NET Premium Edition if you forget to install IIs before installing vs. Net beta 2, you do not need to reinstall the entire vs. Net beta 2 after installing IIS.
Http://download.microsoft.com/download/VisualStudioNET/Trial/2/W982KMeXP/EN-US/setup.exe
Soap Toolkit 2.0 SP2
Http://download.microsoft.com/download/xml/soap/2.0/W98NT42KMe/EN-US/SoapToolkit20.exe
Programming. Net with C #
Http://www.gotdotnet.com/featured_site/developmentor/assemblies2.pdf
XML spy 4.0b2
Http://www.xmlspy.com/download/beta/
Visual XSLT for vs. Net beta2
Http://downloads.activestate.com/VisualXSLT/VisualXSLT-1.0.0-Beta3-1730.msi
Msdn show: vs. Net beta 2
Http://a138.ms.a.microsoft.com/f/138/1611/2h/download.microsoft.com/download
/Visualstudionet/utility/15/win98mexp/en-US/episode015.exe
A good C # editor can also be developed and supports framework SDK beta 2. The new version also provides dynamic function help.
Http://www.c-point.com/download/csharped.zip
Soap extensions with Visual Basic. net
Http://msdn.microsoft.com/msdn-files/026/002/305/VBSoapEx.exe