I have a blocker which I cannot solve. Issue is in auto-generated SOAP request built by SoapFormatter class. I'm trying to communicate with WCF service and pass some data. I've implemented class which I am trying to serialize to soap request.
[Serializable]
public class MySoapClass: ISerializable
{
public string Username{ get; set; }
public string Password{ get; set; }
public int Data3 { get; set; }
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.FullTypeName = "ThisIsNameIWantInSoap";
info.AddValue("Username", Username);
info.AddValue("Password", Password);
info.AddValue("Data3", Data3);
}
}
I'm using MemoryStream and MySoapClass object in SoapFormatter. I am getting soap string this way Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Position)
Generated soap string does not work, request is delivered, but I am getting "authentication error", just like WCF service could not extract any data from request. This is auto-generated soap string:
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:ThisIsNameIWantInSoap id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/assem/http://tempuri.org/">
<Username id="ref-1">username</Username>
<Password id="ref-2">password</Password>
<Data3>10</Data3>
</a1:ThisIsNameIWantInSoap>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
After copying soap string to SoapUI and adding namespace tag to every parameter, everything works fine. I am getting proper response from WCF service.
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:ThisIsNameIWantInSoap id="ref-1" xmlns:a1="http://tempuri.org/">
<a1:Username id="ref-1">username</a1:Username>
<a1:Password id="ref-2">password</a1:Password>
<a1:Data3>10</a1:Data3>
</a1:ThisIsNameIWantInSoap>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
My questions are:
-How to auto-generate soap string which includes "a1:" namespace tag in every parameter?
-(Answered) How to change "a1:" namespace to"somethingElse:"?