1

Input Xml

  <ws:processAcord xmlns:ws="http://ws.plus.predictivelogic.com/">
    <arg0>CrlUser</arg0>
    <arg1>CrlPass</arg1>
    <arg2>Life Scope</arg2>
    <arg3 />
  </ws:processAcord>

Object Class

[XmlRoot(ElementName = "processAcord", Namespace = "http://ws.plus.predictivelogic.com/")]
    public class Input
    {
        //[DataMember]
        [XmlElement(ElementName = "arg0")]
        public string Arg0 { get; set; }
        //[DataMember]
        [XmlElement(ElementName = "arg1")]
        public string Arg1 { get; set; }
        //[DataMember]
        [XmlElement(ElementName = "arg2")]
        public string Arg2 { get; set; }
        //[DataMember]
        [XmlElement(ElementName = "arg3")]
        public string Arg3 { get; set; }
        //[DataMember]
        [XmlAttribute(AttributeName = "ws", Namespace = "http://www.w3.org/2000/xmlns/")]
        public string Ws { get; set; }
    }

service definition

public UnderWritingOutput Get(Input inputXml)
{
//do stuff
}

i'm trying to call my service from SOAPUI, but it's causing problem in serialization. i'm not getting any data in Service when i'm debugging it.

there must be some attribute declaration issue with my code, like [DataContract] or any other xml Attribute.

Update 1:

i already post the service details, here is the binding..

<system.serviceModel>
<services>
  <service name="ServiceApplication.UnderWritingService" behaviorConfiguration="debug">
    <endpoint address="GetUnderWriting" binding="basicHttpBinding" contract="ServiceApplication.IUnderWritingService"></endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:60418/"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>

  <serviceBehaviors>
    <behavior name="debug">
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
    </behavior>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

When i'm opening the soapUI request then it's showing me the input xml as

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:ser="http://schemas.datacontract.org/2004/07/ServiceApplication">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Get>
         <!--Optional:-->
         <tem:inputXml>
            <!--Optional:-->
            <ser:Arg0>?</ser:Arg0>
            <!--Optional:-->
            <ser:Arg1>?</ser:Arg1>
            <!--Optional:-->
            <ser:Arg2>?</ser:Arg2>
            <!--Optional:-->
            <ser:Arg3>?</ser:Arg3>
            <!--Optional:-->
            <ser:Ws>?</ser:Ws>
         </tem:inputXml>
      </tem:Get>
   </soapenv:Body>
</soapenv:Envelope>

IUnderWritingService

[ServiceContract]
    public interface IUnderWritingService
    {
        [OperationContract]
        UnderWritingOutput Get(UnderWritingInput inputXml);

    }
A_Sk
  • 4,532
  • 3
  • 27
  • 51
  • SoapUI thinks your operation and message is in the namespace `xmlns:tem="http://tempuri.org/"` while your first xml shows different namespaces. What is the one you want to happen? – rene Dec 21 '16 at 11:07
  • First XML iv'e posted here, should be the Input for my service. – A_Sk Dec 21 '16 at 11:14
  • But you do want it to be an SOAP webservice, right? Not a REST service with a simple post? – rene Dec 21 '16 at 11:23

2 Answers2

1

Your XML structure can't be serialized by the DataContract serializer as it doesn't like the fact that elements are in different Namespaces. If that XML format is required, tell the WCF stack to use the XmlSerializer instead by adding the the attribute [XmlSerializerFormat]

[XmlRoot(ElementName = "processAcord", Namespace = "http://ws.plus.predictivelogic.com/")]
[XmlSerializerFormat]  // tell WCF to not to use the DataContractSerializer
public class Input
{
    [XmlElement(ElementName = "arg0", Namespace = "")]
    public string Arg0 { get; set; }
    [XmlElement(ElementName = "arg1", Namespace = "")]
    public string Arg1 { get; set; }
    [XmlElement(ElementName = "arg2", Namespace = "")]
    public string Arg2 { get; set; }
    [XmlElement(ElementName = "arg3", Namespace = "")]
    public string Arg3 { get; set; }
    [XmlAttribute(AttributeName = "ws", Namespace = "http://www.w3.org/2000/xmlns/")]
    public string Ws { get; set; }
}

The following LinqPad test rig demonstrate that this does render result:

var xml = @"<ws:processAcord xmlns:ws=""http://ws.plus.predictivelogic.com/"">
<arg0>CrlUser</arg0>
<arg1>CrlPass</arg1>
<arg2>Life Scope</arg2>
<arg3 />
</ws:processAcord>";

var xs = new XmlSerializer(typeof(Input));
var rdr = XmlReader.Create(new StringReader(xml));
var obj = (Input) xs.Deserialize(rdr);
obj.Dump();

When executed, this is the result:

result of deserialized object

If you rather use the DataContractSerializer, you have to change your xml so the arg0, arg1, arg2 and arg3 elements are also in the ws namespace, like so: <ws:arg0>CrlUser</ws:arg0>

Next thing is to make sure your service does understand that payload. Your ServiceContract should hold the namespace:

[ServiceContract(Namespace="http://ws.plus.predictivelogic.com/"]
public interface IUnderWritingService
{
    [OperationContract]
    UnderWritingOutput Get(UnderWritingInput inputXml);

}

You didn't state this explicitly but be aware of the possibility that the datacontract is wrapped

Community
  • 1
  • 1
rene
  • 41,474
  • 78
  • 114
  • 152
  • hi, when i'm posting it from soapUI then it's not serializing, i'm getting `null` in input parameter. – A_Sk Dec 21 '16 at 10:45
  • I need to see your ServiceContract classes and interfaces then, as well as your binding if that is configured in the .config. – rene Dec 21 '16 at 10:47
  • What does your ServiceApplication.IUnderWritingService looks like because your SoapUI is suggesting way different namespaces then your example XML. Which one is correct? – rene Dec 21 '16 at 11:01
  • sorry, i'm new to WCF so i don't have any idea about this, please see the updated question. – A_Sk Dec 21 '16 at 11:13
  • The servicecontract should at least have the namespace. see my update – rene Dec 21 '16 at 11:24
  • i'm sorry, it's still not working,leave it, thank you. you tried a lot. thank you so much. – A_Sk Dec 21 '16 at 11:38
-1

You need to put [DataContract] attribute on the Input class to make it serializable. Also, decorate each property of this class with [DataMember] attribute, that you want to be serialized.

Rohit Garg
  • 493
  • 2
  • 12