Forum Discussion

ProdipK's avatar
ProdipK
Occasional Contributor
12 years ago

SoapUI Request Handcrafted for .Net Remoting Service

SoapUI is an wonderful time saving tool to test your codes. Yes, it does allow you to add wsdl and auto configure the request envelop but would not it be nice if you know how to handcraft the soap request when you don't have the wsdl? Here is a simple example that I used to test .net remoting service but you can apply the same steps to configure request to test services running on other technologies.

<!-- SoapUI Request Handcrafted for .Net Remoting Service. -->
<!-- This request attach header of data contract type. The DLL is strongly named. -->
<!-- The header is added to LogicalCallContext. -->
<!-- Add Soapheader: SOAPAction = http://schemas.microsoft.com/clr/nsassem/namespace-of-service.ServiceClassName/ServiceDLLName#AddOperation -->
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://schemas.microsoft.com/clr/nsassem/namespace-of-service.ServiceClassName/ServiceDLLName">
<soapenv:Header>
<h4:__CallContext href="#ref-3" xmlns:h4="http://schemas.microsoft.com/clr/soap/messageProperties"/>
<a1:LogicalCallContext id="ref-3" xmlns:a1="http://schemas.microsoft.com/clr/ns/System.Runtime.Remoting.Messaging">
<ClientInformation href="#ref-6"/>
</a1:LogicalCallContext>
<ns2:DataContractClassNameNoNameSpace id="ref-6"
xmlns:ns2="http://schemas.microsoft.com/clr/nsassem/DataContractNamespace.ContractClassName/DataContractDLLName%2C%20Version%3D1.0.0.0%2C
%20Culture%3Dneutral%2C%20PublicKeyToken%1Ea568g78r589r35s1">
<DataContractProperty1>Any</DataContractProperty1>
<DataContractProperty2>${=java.util.UUID.randomUUID()}</DataContractProperty2>
<DataContractProperty3>${=new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new Date())}</DataContractProperty3>
</ns2:DataContractClassNameNoNameSpace >
</soapenv:Header>
<soapenv:Body>
<ns1:AddOperation soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Value1 xsi:type="xsd:long">500</Value1>
<Value2 xsi:type="xsd:long">123</Value2>
</ns1:AddOperation>
</soapenv:Body>
</soapenv:Envelope>

1 Reply

  • ProdipK's avatar
    ProdipK
    Occasional Contributor
    Here is little more..
    Soap serialization is tricky and it is much more harder if your class objects don't explicitly implement ISerializable interface. .Net Soap serializer does not know how to map the property of Employee unless you know the name of the underlying backing fields (funny looking names!). You have to scratch your head to figure out the backing field names or you can implement the ISerializable interface to gaurantee
    the serialization (you can even debug it!).

    using System;
    using System.Xml.Serialization;
    using System.Runtime.Serialization;

    namespace My.Concept.Contract
    {
    [Serializable]
    public class Employee //: ISerializable
    {
    public string Name { get; set; }
    public int Id { get; set; }

    public Employee() { }

    //public Employee(SerializationInfo info, StreamingContext context)
    //{
    // Name = (string)info.GetValue("Name", typeof(string));
    // Id = (int)info.GetValue("Id", typeof(int));
    //}
    //public void GetObjectData(SerializationInfo info, StreamingContext context)
    //{
    // info.AddValue("Name", Name);
    // info.AddValue("Id", Id);
    //}
    }
    }

    //this is implementation operation
    //ns=My.Concept.Server
    //class=SampleRemoteService
    //dll=My.Concept.Server
    public int TestByRef(int any, ref Employee employee)
    {
    any = 123;

    employee.Id = 123;
    employee.Name = "Jimmy";

    return any;
    }