我正在创建.asmx端点,以便第三方可以向我发送肥皂请求。 第三方示例如下所示:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://catmanager.com/schemas/catmanager/v8.8.2/notify">
<soapenv:Header/>
<soapenv:Body>
<tns:notifyCatExtendedStatusChange xmlns:tns="http://catmanager.com/schemas/catmanager/v8.8.0/notify">
<CatJob>
<not:CatCode>FTC</not:CatCode>
<not:ClientStatus>URGENT</not:ClientStatus>
</CatJob>
</not:notifyCatExtendedStatusChange>
</soapenv:Body>
</soapenv:Envelope>
当我使用服务中的wsdl创建SOAPUI项目时,我的xml期待这样:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:not="http://catmanager.com/schemas/catmanager/v8.8.2/notify">
<soapenv:Header/>
<soapenv:Body>
<not:notifyCatExtendedStatusChange>
<CatJob>
<not:CatCode>Bernard</not:CatCode>
<not:ClientStatus>NOT URGENT</not:ClientStatus>
</CatJob>
</not:notifyCatExtendedStatusChange>
</soapenv:Body>
</soapenv:Envelope>
我需要我的服务接受 tns 而非不的请求。
我想我需要强制使用前缀,但我无法解决如何执行此操作的问题。 我发现此链接看起来非常复杂,但如果没有更简单的方法,我会尝试下一步:\ n \ n http://benscoderepo.blogspot.co.uk/2014/12/adding-soap-prefix-to-asmx-service.html
这是我的asmx代码:
using System.ComponentModel;
using System.Web.Services;
using System.Web.Services.Description;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
namespace CatApp
{
[WebService(Namespace = "http://catmanager.com/schemas/catmanager/v8.8.2/notify")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class CatService : System.Web.Services.WebService
{
[WebMethod]
[SoapRpcMethod("urn:notifyCatExtendedStatusChange",RequestNamespace = "http://catmanager.com/schemas/catmanager/v8.8.2/notify", ResponseNamespace = "http://catmanager.com/schemas/catmanager/v8.8.2/notify", Use = SoapBindingUse.Literal)]
[return: XmlElement("UpdateCatExtendedStatusResponse")]
public string notifyCatExtendedStatusChange(catJob CatJob)
{
return CatJob.ClientStatus;
}
}
public class catJob
{
public string CatCode { get; set; }
public string ClientStatus { get; set; }
}
public partial class updateCatExtendedStatusResponse
{
private int idField;
private bool statusUpdatedField;
[XmlElementAttribute(Form = global::System.Xml.Schema.XmlSchemaForm.Unqualified)]
public int Id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
[XmlElementAttribute(Form = global::System.Xml.Schema.XmlSchemaForm.Unqualified)]
public bool StatusUpdated
{
get
{
return this.statusUpdatedField;
}
set
{
this.statusUpdatedField = value;
}
}
}
}
我改变了
Use = SoapBindingUse.Literal
到
Use = SoapBindingUse.Default
它开始使用第三方示例。我将它切换回Literal,它仍然有效。我很神秘,但我很高兴一切都开始发挥作用。
答案 0 :(得分:0)
问题不是前缀。问题是第三方意外发送了错误的名称空间: