question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for parameterless operation contracts

See original GitHub issue

Hi, for some of our message contracts we need to to accept soap messages without a body. As far as i can see is currently not supported.

For example, we need to accept echo response pings via this message:

POST https://localhost:5001/service.svc HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "EchoResponse"
Content-Length: 139
Host: localhost:5001
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/12.0.1)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body/>
</soapenv:Envelope>

Unfortunately this results in the following exceptions:

Exception when generating the wsdl on service startup:

System.ArgumentOutOfRangeException
  HResult=0x80131502
  Message=Index was out of range. Must be non-negative and less than the size of the collection. 
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowArgumentOutOfRange_IndexException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at SoapCore.Meta.MetaBodyWriter.GetMessageContractBodyType(Type type)
   at SoapCore.Meta.MetaBodyWriter.WriteParameters(XmlDictionaryWriter writer, SoapMethodParameterInfo[] parameterInfos, Boolean isMessageContract)
   at SoapCore.Meta.MetaBodyWriter.AddTypes(XmlDictionaryWriter writer)
   at SoapCore.Meta.MetaBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.Message.WriteBodyContents(XmlDictionaryWriter writer)
   at SoapCore.Meta.MetaMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.Message.WriteMessage(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.Message.WriteMessage(XmlWriter writer)
   at SoapCore.MessageEncoder.SoapMessageEncoder.WriteXmlCore(Message message, XmlWriter xmlWriter)
   at SoapCore.MessageEncoder.SoapMessageEncoder.<WriteMessageAsync>d__27.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

  This exception was originally thrown at this call stack:
    System.ThrowHelper.ThrowArgumentOutOfRange_IndexException()
    System.Collections.Generic.List<T>.this[int].get(int)
    SoapCore.Meta.MetaBodyWriter.GetMessageContractBodyType(System.Type)
    SoapCore.Meta.MetaBodyWriter.WriteParameters(System.Xml.XmlDictionaryWriter, SoapCore.ServiceModel.SoapMethodParameterInfo[], bool)
    SoapCore.Meta.MetaBodyWriter.AddTypes(System.Xml.XmlDictionaryWriter)
    SoapCore.Meta.MetaBodyWriter.OnWriteBodyContents(System.Xml.XmlDictionaryWriter)
    System.ServiceModel.Channels.BodyWriter.WriteBodyContents(System.Xml.XmlDictionaryWriter)
    System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(System.Xml.XmlDictionaryWriter)
    System.ServiceModel.Channels.Message.WriteBodyContents(System.Xml.XmlDictionaryWriter)
    SoapCore.Meta.MetaMessage.OnWriteBodyContents(System.Xml.XmlDictionaryWriter)
    ...
    [Call Stack Truncated]

Exception when the service operation is invoked:

System.InvalidOperationException
  HResult=0x80131509
  Message=The body of the message cannot be read because it is empty.
  Source=System.Private.ServiceModel
  StackTrace:
   at System.ServiceModel.Channels.Message.GetReaderAtBodyContents()
   at SoapCore.SoapEndpointMiddleware`1.<ProcessOperation>d__20.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

  This exception was originally thrown at this call stack:
    System.ServiceModel.Channels.Message.GetReaderAtBodyContents()
    SoapCore.SoapEndpointMiddleware<T_MESSAGE>.ProcessOperation(Microsoft.AspNetCore.Http.HttpContext, System.IServiceProvider)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

It would be nice if the library could support this. If you like i can create a pull request with a resolution.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rinkebcommented, Jan 11, 2021

Thanks. The new nuget works perfectly in my project setup.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Good and bad ways to use operation contracts.
Good and bad ways to use operation contracts. · 3 · I can only see the method being bad by having an excessive...
Read more >
Specifying Data Transfer in Service Contracts - WCF
This topic explains the various ways in which an operation contract can describe messages. Describing Messages by Using Parameters. The simplest ...
Read more >
Function CallAsync: No parameterless constructor defined ...
Using Contract code: function getName() constant returns (byte[100] name){ return areaName; } Which appears in my abi as: { "constant": true ...
Read more >
JP 4-10, Operational Contract Support, 4 March 2019
This publication provides fundamental principles and guidance for planning, executing, and managing operational contract support in all phases ...
Read more >
Operational Contract Support (OCS) Outside the United ...
Operational Contract Support (OCS) is how the Department plans for and integrates contracted capabilities and associated contractor ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found