Change ASP.NET generated by WSDL for ASP.NET web service

Is there a way to change the way asp.net elements are created in the WSDL generated from the .asmx file? In particular, it seems that all elements minoccurs = "0" are marked, and there are some elements that I want to be minoccurs = "1" (aka required fields).

One of them is the web service argument (for example, foo (arg1, arg2), where I want arg2 to be generated in WSDL as minoccurs = "1"), the other is a specific field in the class that matches arg1. Should I abandon the automatic generation of WSDL and use the "first contract"?

+3
source share
3 answers

I think the attribute XmlElement(IsNullable = true)will complete the task:

using System.Xml.Serialization;

[WebMethod]
public string MyService([XmlElement(IsNullable = true)] string arg)
{
  return "1";
}

[ VB]

Imports System.Xml.Serialization

Public Function MyService(<XmlElement(IsNullable:=True)> ByVal arg As String) As String
  Return ("1")
End Function
+7

XMLElement (IsNullable = true) minOccurs = 1, WSDL nillable = "true", .

+2

, ( WCF), - [XmlSchemaProvider]. , , WSDL.

, , , WSDL, , .NET . WSDL - (, , ), http://url/service.wsdl service.asmx? wsdl.

+1

Source: https://habr.com/ru/post/1698107/


All Articles