我有一个.NET 4.5客户端,它调用了soap服务方法。使用提琴手通过电线正确地调用了该方法,我可以说响应返回了,并且该方法调用成功了。
示例方法调用响应:
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<executeResponse>
<Number>EEI0002278</Number>
<SysID>a2750b4fdbb9a7c0b6e69b3c8a9619ff</SysID>
<Status>200</Status>
<Message>COI case generated</Message>
</executeResponse>
</SOAP-ENV:Body>
我的客户端.config文件
<system.serviceModel>
<bindings>
<customBinding>
<binding name="WsHttpSoap11">
<security enableUnsecuredResponse="true" authenticationMode="CertificateOverTransport" />
<textMessageEncoding messageVersion="Soap11" />
<context />
<httpsTransport authenticationScheme="Basic" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://gateway-cs.company.com:8888/COICaseGenerator.do"
binding="customBinding" bindingConfiguration="WsHttpSoap11"
contract="ServiceNowSoap" name="Soap11" />
</client>
</system.serviceModel>
数据合同:
[DataContract(Namespace = "http://www.company.com/COICaseGenerator")]
public class executeResponse
{
private string numberField;
private string sysIDField;
private string statusField;
private string messageField;
[DataMember(Name="Number", Order = 0)]
public string Number
{
get
{
return this.numberField;
}
set
{
this.numberField = value;
}
}
[DataMember(Name = "SysID", Order = 1)]
public string SysID
{
get
{
return this.sysIDField;
}
set
{
this.sysIDField = value;
}
}
[DataMember(Name = "Status", Order = 2)]
public string Status
{
get
{
return this.statusField;
}
set
{
this.statusField = value;
}
}
[DataMember(Name = "Message", Order = 3)]
public string Message
{
get
{
return this.messageField;
}
set
{
this.messageField = value;
}
}
[OnDeserialized()]
public void OnDeserialized(StreamingContext c)
{
//if (MyCustonObj == null)
//{
// MyCustonObj = new MyCustomClass();
// MyCustonObj.MyStrData = "Overridden in serialization";
//}
}
[OnDeserializing()]
public void OnDeserializing(StreamingContext c)
{
//if (MyCustonObj == null)
//{
// MyCustonObj = new MyCustomClass();
// MyCustonObj.MyStrData = "Overridden in deserializing";
//}
}
[OnSerialized()]
public void OnSerialized(StreamingContext c)
{
// if you wan to do somehing when serialized here or just remove them
}
[OnSerializing()]
public void OnSerializing(StreamingContext c)
{
// if you wan to do somehing during serializing here or just remove them
}
}
Svcutil.exe生成:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="", ConfigurationName="ServiceNowSoap")]
public interface ServiceNowSoap
{
[System.ServiceModel.OperationContractAttribute()]
executeResponse execute(CoiCase coiCase);
[System.ServiceModel.OperationContractAttribute()]
void executeAsync();
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface ServiceNowSoapChannel : ServiceNowSoap, System.ServiceModel.IClientChannel
{
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class ServiceNowSoapClient : System.ServiceModel.ClientBase<ServiceNowSoap>, ServiceNowSoap
{
public ServiceNowSoapClient()
{
}
public ServiceNowSoapClient(string endpointConfigurationName) :
base(endpointConfigurationName)
{
}
public ServiceNowSoapClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
}
public ServiceNowSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}
public void executeAsync()
{
base.Channel.executeAsync();
}
public executeResponse execute(CoiCase coiCase)
{
return base.Channel.execute(coiCase);
}
}
问题:
调用服务方法(executeResponse execute(CoiCase coiCase)) 返回null。即使在提琴手中响应消息看起来正确。
和以下反序列化方法从不调用。我设置了断点,但是它们从未被击中。
public void OnDeserialized(StreamingContext c)
public void OnDeserializing(StreamingContext c)
public void OnSerialized(StreamingContext c)
public void OnSerializing(StreamingContext c)