我通过另一个用PHP制作的Web服务的WSDL创建了一个C#webservice。所有调用都有效,但xml中发送的参数始终为空。 这是我的代码:
[WebService(Namespace = "urn:PGSMS")]
[GeneratedCode("System.Xml", "2.0.50727.3082")]
[System.Xml.Serialization.SoapType(Namespace = "urn:PGSMS")]
[SoapDocumentService(RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
[System.Web.Script.Services.ScriptService]
public class PGSMS : System.Web.Services.WebService, PGSMSPortType
{
[WebMethod]
[OperationContract(Action = "urn:PGSMS#PGSMS")]
public string envioAvulso(string token, string carteira, string msg, string fones, string data, string retorno, string dadocliente)
{
IntegraBellinati.envioAvulsoRequest envio = new IntegraBellinati.envioAvulsoRequest();
envio.token = token;
envio.msg = msg;
envio.fones = fones;
envio.carteira = carteira;
envio.data = data;
envio.dadocliente = dadocliente;
envio.retorno = retorno;
IntegraBellinati.IntegraBellinati integra = new IntegraBellinati.IntegraBellinati();
return integra.envioAvulso(envio);
}
}
[System.ServiceModel.ServiceContract(Namespace = "urn:PGSMS", ConfigurationName = "PGSMSPortType")]
public interface PGSMSPortType
{
string envioAvulso(string token, string carteira, string msg, string fones, string data, string retorno, string dadocliente);
}
方法sendingAvulso正常执行,但所有方法都为null。 这是我的客户试图发布的xml:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:PGSMS" xmlns:types="urn:PGSMS/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:envioAvulso>
<token xsi:type="xsd:string">xxxxxxxxxxxxxxxx</token>
<carteira xsi:type="xsd:string">12</carteira>
<msg xsi:type="xsd:string">Teste de msg</msg>
<fones xsi:type="xsd:string">41988326802</fones>
<data xsi:type="xsd:string">2017-10-09 00:00:00</data>
<retorno xsi:type="xsd:string">12</retorno>
<dadocliente xsi:type="xsd:string">12</dadocliente>
</tns:envioAvulso>
</soap:Body>
</soap:Envelope>
使用SoapUI我能够发布帖子并收到正确的参数,它生成了这个xml。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:PGSMS">
<soapenv:Header/>
<soapenv:Body>
<urn:envioAvulso>
<urn:token>?</urn:token>
<urn:carteira>?</urn:carteira>
<urn:msg>?</urn:msg>
<urn:fones>?</urn:fones>
<urn:data>?</urn:data>
<urn:retorno>?</urn:retorno>
<urn:dadocliente>?</urn:dadocliente>
</urn:envioAvulso>
</soapenv:Body>
</soapenv:Envelope>
但我的客户无法更改他的xml。我能做错什么? 感谢的