Problems encountered in WEBSERVICE Learning

Source: Internet
Author: User
I sent a GET request to my WEBSERVICE.
Http: // 127.0.0.1/VegService. asmx/Getvegetable? Vegetablename = cucumber
Then an error is returned.

"/" Indicates a server error in the application.

The request format cannot be identified.

Note:An error occurred while executing the current Web request. Check the stack trace information for details about the error and the source of the error in the code.

Exception details:System. InvalidOperationException: The request format cannot be recognized.

Source error:

An unhandled exception is generated during the execution of the current Web request. You can use the following exception stack trace information to determine the cause and location of the exception.

Stack trace:

[InvalidOperationException: The request format cannot be identified.] System. web. services. protocols. webServiceHandlerFactory. coreGetHandler (Type type, HttpContext context, HttpRequest request, HttpResponse response) + 388 System. web. services. protocols. webServiceHandlerFactory. getHandler (HttpContext context, String verb, String url, String filePath) + 94 System. web. httpApplication. mapHttpHandler (HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) + 699 System. web. mapHandlerExecutionStep. system. web. httpApplication + IExecutionStep. execute () + 95 System. web. httpApplication. executeStep (IExecutionStep step, Boolean & completedSynchronously) ++ 173

Version:Microsoft. NET Framework Version: 1.1.4322.573; ASP. NET version: 1.1.4322.573

The original webservice program is as follows:

<% @ WebService Language = "vb" Class = "Vegetables. Vegservice" %>

Imports system
Imports system. web. services
Imports system. web. services. protocols
Imports system. xml

Namespace Vegetables


<Webservice (namespace: = "http://hx66.com/net")> public class Vegservice
Inherits system. web. services. webservice

Public enum Appearance
Round
Bendy
Odd
End enum

Public structure Vegetable
Public VegName as string
Public VegColor as string
Public VegLooks as Appearance
Public NumberInStock as integer
End structure
<Webmethod ()> Public function GetVegetable (byval vegetablename as string) as Vegetable
'Context. request. saveas ("c: \ VegServiceRequest.htm", false)
Dim result as Vegetable

Select Case vegetablename. tolower ()
Case "cucumber"
Result. VegName = "Cucumber"
Result. VegColor = "Green"
Result. VegLooks = Appearance. Bendy
Result. NumberInStock = 10
Case "sweetcorn"
Result. VegName = "Sweetcorn"
Result. VegColor = "Yellow"
Result. VegLooks = Appearance. Odd
Result. NumberInStock = 2
Case "potato"
Result. VegName = "Potato"
Result. VegColor = "Brown"
Result. VegLooks = Appearance. Round
Result. NumberInStock = 55
Case else
Dim code as xmlqualifiedname
Code = new xmlqualifiedname ("Sender", "http://schemas.xmlsoap.org/soap/envelope ")
Dim doc as xmldocument
Doc = new xmldocument ()
Dim detail as xmlelement
Detail = doc. createelement ("detail ")
Dim veg as xmlelement
Veg = doc. createelement ("vegFault", "vegetableName", "http://www.hx66.com/net/vegservice/faults ")
Veg. innertext = vegetablename
Detail. Appendchild (veg)
Doc. appendchild (detail)
Throw new soapexception ("Unknown vegetable.", code, "http://www.hx66.com/net/vegservice", doc)
End select
Return result
End function

<Webmethod ()> public function GetVegetables (byval vegetablenames as string () as Vegetable ()
'Context. request. Saveas ("c: \ VegServiceRequest.htm", false)
Dim results () as Vegetable
Results = new Vegetable (vegetablenames. length ){}

Dim resultNum as integer
For resultNum = 0 to results. length-1 step resultNum + 1
Results (resultNum) = GetVegetable (vegetablenames (resultNum ))
Next

Return results
End function
End class
End namespace


I installed the. net framework SDK on the machine.
I don't know why.
It seems that the GET method is not accepted.
You can directly click the method to submit parameters on the page.

Please help me !!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.