My development environment is win11, visual studio 2022, .net 7
1. Right click on the connection service and select manage connection service
2. Click + or add service reference
3. The following is the webservice address of the translation I am looking for, fill in the address. Click go and enter the namespace. Click Next
http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx?wsdl
Click Next
click finish
Generated class files
call method in code
/// <summary>
/// http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx?wsdl
/// </summary>
/// <returns></returns>
[HttpGet(Name = " getEnCnTwoWayTranslator")]
public string[] getEnCnTwoWayTranslator(string words)
{
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx?wsdl");
TranslatorWebServiceSoapClient client = new TranslatorWebServiceSoapClient(binding, address);
getEnCnTwoWayTranslatorRequest request = new getEnCnTwoWayTranslatorRequest();
request.Word = words;
Task<getEnCnTwoWayTranslatorResponse> response3 = client.getEnCnTwoWayTranslatorAsync(request);
string [] aa = response3.Result .getEnCnTwoWayTranslatorResult;
return aa;
}
The following is the call result display