AKANDOUCH

when using RPC/Encoded mode in Webservice , the IsNullable=false is ignored in the WSDL file:

I have the class (generated from xsd file) that contains the following attributes:

/// <remarks/>

[System.Xml.Serialization.XmlElementAttribute(IsNullable=false)]

public string CorporateName;

/// <remarks/>

[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]

public string Type;

/// <remarks/>

[System.Xml.Serialization.XmlElementAttribute(IsNullable=false)]

public string ID;

When using document/literal webservice , i get this element in the wsdl file.

<s:element minOccurs="0" maxOccurs="1" name="CorporateName" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="Type" nillable="true" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ID" type="s:string" />
B
BUT when i use RPC/Encoded mode i get all element whith minoccurs=1 and maxoccurs=1 ( IsNullable attribute is ignored)
<s:element minOccurs="1" maxOccurs="1" name="CorporateName" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="Type" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="ID" type="s:string" />
Windows XP. Visual Studio 2003. framework.net 1.1 .WebService RPC




Re: ASMX Web Services and XML Serialization WebService RPC/Encoded


Re: ASMX Web Services and XML Serialization WebService RPC/Encoded

AKANDOUCH

thanks for Clemens.

the use of SOAP attributes did not solve the problem. the following code is an example code webservice :
namespace WebService1
{
[SoapRpcService(RoutingStyle=SoapServiceRoutingStyle.SoapAction)]
[WebService(Namespace="http://soapinterop.org/")]
public class Service1 : System.Web.Services.WebService
{
public Service1()
{InitializeComponent();}
#region Component Designer generated code
//Required by the Web Services Designer
private IContainer components = null;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent(){}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{if(disposing && components != null)
{components.Dispose();}
base.Dispose(disposing); }
#endregion
//My WebMethod
[SoapRpcMethod ]
[WebMethod]
public string HelloWorld(perso p)
{return p.name ;}
}
//My Class
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://com", IsNullable=false)]
public class perso
{
[SoapElement(IsNullable = true)]
public string name;
[SoapElement(IsNullable = false)]
public int age;
}
}

This WSDL of this web Service is:

< xml version="1.0" encoding="utf-8" >

- <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://soapinterop.org/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://soapinterop.org/" xmlns="http://schemas.xmlsoap.org/wsdl/">
- <types>
- <s:schema targetNamespace="http://soapinterop.org/">
- <s:complexType name="perso">
- <s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="name" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="age" type="s:int" />
</s:sequence>
</s:complexType>
</s:schema>
</types>
- <message name="HelloWorldSoapIn">
<part name="p" type="s0:perso" />
</message>
- <message name="HelloWorldSoapOut">
<part name="HelloWorldResult" type="s:string" />
</message>
- <portType name="Service1Soap">
- <operation name="HelloWorld">
<input message="s0:HelloWorldSoapIn" />
<output message="s0:HelloWorldSoapOut" />
</operation>
</portType>
- <binding name="Service1Soap" type="s0:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
- <operation name="HelloWorld">
<soap:operation soapAction="http://soapinterop.org/HelloWorld" style="rpc" />
- <input>
<soap:body use="encoded" namespace="http://soapinterop.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
- <output>
<soap:body use="encoded" namespace="http://soapinterop.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
- <service name="Service1">
- <port name="Service1Soap" binding="s0:Service1Soap">
<soap:address location="http://localhost/WebService1/Service1.asmx" />
</port>
</service>
</definitions>

thanks to analyze my code