SoapCore icon indicating copy to clipboard operation
SoapCore copied to clipboard

Strange problem with unwrapped messages

Open royjacob opened this issue 10 months ago • 3 comments

Hi Guys.

Great tool, though I have found an odd issue if I try and create unwrapped messages, for example;

[MessageContract(IsWrapped = false)] 
public class SomeRequest
{
    [XmlIgnore]
    public required RequestHeaderType requestHeaderField;

    [XmlIgnore]
    public required ProfileType profileField;

    /// <remarks/>
    [MessageBodyMember (Order = 0)]
    public RequestHeaderType RequestHeader
    {
        get
        {
            return this.requestHeaderField;
        }
        set
        {
            this.requestHeaderField = value;
        }
    }

    //This is ignored when using MessageContract(isWarpped=false)
    [MessageBodyMember (Order = 1)]
    public ProfileType Profile
    {
        get
        {
            return this.profileField;
        }
        set
        {
            this.profileField = value;
        }
    }
}

And the Profile type contains a polymorphic attribute:

[XmlType(Namespace="http://blaa/Report/fqs/xsd/ReportTypes/v1")]
[DataContract(Namespace = "http://blaa/Report/fqs/xsd/ReportTypes/v1")]
public class ProfileType
{
    [XmlIgnore()]
    public required object itemField;


    [XmlElement("Individual", typeof(IndividualType), Order=0)]
    [XmlElement("Organisation", typeof(OrganisationType), Order=0)]
    public object Item
    {
        get
        {
            return this.itemField;
        }
        set
        {
            this.itemField = value;
        }
    }
}

Finally the interface is defined like so:

[ServiceContract(Namespace = "http://justice.govt.nz/blaa/fqs/xsd/ReportTypes/v1")]
public interface CreditReportService
{
    [OperationContract()]
    //string Sum(int num1, int num2);
    CreditRequest.FinesQueryResponseType finesBalanceRequest(CreditRequest.FinesBalanceRequest request);
}

Not that I have made the response message un wrapped as well.

The result is an attenuated WSDL, where only the first property in the Request message is included, Profile is omitted and all of it's nested types are also missing.

If I treat the message as standard

[DataContract(Namespace = "http://justice.govt.nz/CreditReport/fqs/xsd/CreditReportTypes/v1")]
[XmlRoot(Namespace="http://justice.govt.nz/CreditReport/fqs/xsd/CreditReportTypes/v1")]
public class FinesBalanceRequest
{
    [XmlElement(Order=0)]
    public RequestHeaderType RequestHeader

    //This will now show up
    [XmlElement(Order=1)]
    public ProfileType Profile
}

Then the profile and all it's nested types are included in the WSDL, including the polymorphic property.

I have tried this without the polymorphism, but I get the same result it's like it;s just nmot seeing the second property in the message contract.

Is there another way to define an Unwrapped Message Contract that includes all the embedded XML? Or is this a bug?

royjacob avatar Jan 15 '26 03:01 royjacob

Could it be related to this: Line 78 of MetaBodyWrite.cs

private static string GetOuterInputElementName(OperationDescription operation) { var inParameters = operation.InParameters; if (operation.IsMessageContractRequest && !IsWrappedMessageContractType(inParameters[0].Parameter.ParameterType)) { var messageBodyMember = inParameters[0].Parameter.ParameterType .GetPropertyOrFieldMembers().FirstOrDefault(x => x.GetCustomAttributes(typeof(MessageBodyMemberAttribute), false).Any());

			if (messageBodyMember != null)
			{
				return messageBodyMember.Name;
			}
		}

		return operation.Name;
	}

So only the first body member is ever used?

royjacob avatar Jan 15 '26 04:01 royjacob

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Feb 15 '26 04:02 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Mar 01 '26 04:03 github-actions[bot]