ASMX service parameter (type string) has null value when invoked from WCF client
-
21-09-2019 - |
Question
I am trying to consume an existing ASMX service using WCF with a BasicHttpBinding. I used SvcUtil to get me started and just extracted the contract definition interface and the config in to my project leaving all default configuration values as generated by SvcUtil. The following is what I have currently:
Contract:
<ServiceContract()> _
<XmlSerializerFormat()> _
Public Interface IOrderProcessor
<OperationContract(Action:="***************/SendOrder", _
ReplyAction:="*")> _
Function SendOrder(ByVal strOrder As String) As String
<OperationContract(Action:="***************/GetAnswerback", _
ReplyAction:="*")> _
Function GetAnswerback(ByVal strAnswerbackGuid As String) As String
And Config:
<basicHttpBinding>
<binding name="OrderProcessor" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
The problem I am having is that the parameter value for strOrder of SendOrder service received by the asmx service is always null (I am definitely not providing null at my end :)
Am I missing something obvious? Where is a good place to start to debug this?
EDIT Used XMLSerializer for the serializer switch to SvcUtil
Solution
OK found the answer, I missed the Namespace property on the ServiceContract attribute. Ooopsy!! Should have been:
<ServiceContract([Namespace]:="***************")> _
<XmlSerializerFormat()> _
Public Interface IOrderProcessor
<OperationContract(Action:="***************/SendOrder", _
ReplyAction:="*")> _
Function SendOrder(ByVal strOrder As String) As String
<OperationContract(Action:="***************/GetAnswerback", _
ReplyAction:="*")> _
Function GetAnswerback(ByVal strAnswerbackGuid As String) As String
Why is this the resulting behaviour though? i.e. the service is invoked fine but the parameter value is not passed on...I assume it worked out the namespace from the Action property on the OperationContract attributes.