การเรียกใช้งาน Web Services ใน Visual Studio 2017

winform call web services

สร้างโปรเจ็กส์

File > New > Project…
เลือกโปรเจ็กส์แบบ Windows Classic Desktop > Windows Forms App (.NET Framework)
ตั้งชื่อโปรเจ็กส์ JackWinForm

เพิ่ม Web Services References

คลิกขวาที่ References > Add Service References…
ใส่ url ของ Web Services เช่น http://localhost:62668/MyWebService.asmx กด Go
เลือก MyWebService > MyWebServiceSoap
ตั้งชื่อ MyServiceReference

Continue reading

การสร้าง Web Services ใน Visual Studio 2017

Web Services

สร้างโปรเจ็กส์

File > New > Project…
เลือกโปรเจ็กส์แบบ Web > ASP.NET Web Application (.NET Framework)
ตั้งชื่อโปรเจ็กส์ JackWebServices
เลือก Empty

เพิ่มไฟล์ Web Services

คลิกขวาที่ JackWebServices เลือก Add > New Item…
เลือก Web Services (ASMX)
ตั้งชื่อไฟล์ MyWebService.asmx

Continue reading

การสร้าง Web Services และเรียกใช้งาน Web Services ด้วย Visual Studio 2015

สร้าง 2 โปรเจ็กส์

โปรเจ็กส์ 1: สร้างโปรเจ็กส์ให้บริการเว็บเซอร์วิส มีเว็บเมธอดให้บริการ 2 เมธอด

  • มีเว็บเมธอด HelloWorld() คืนค่าเป็นสตริง Hello World
  • มีเว็บเมธอด ConvertTemperature() รับพารามิเตอร์เป็นองศาฟาเรนไฮ และคืนค่าเป็นองศาเซลเซียส
  • สามารถเรียกดู WSDL ได้ด้วยการใส่ ?wsdl ต่อท้าย เช่น  xxx.asmx?wsdl

โปรเจ็กส์ 2: สร้างโปรเจ็กส์วินโดว์เดสท็อป เรียกใช้งานเว็บเซอร์วิส

  • เรียกใช้งานเว็บเมธอด ConvertTemperature()

Visual Studio 2017

ถ้าใช้ Visual Studio 2017 ให้เพิ่ม Tag ต่อไปนีั้ที่  web.config

Ref stackoverflow.com – Request format is unrecognized for URL unexpectedly ending in