I'm creating a .asmx endpoint so a third party can send me a soap request. The third party example looks like this:
我正在创建.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>
When I create a SOAPUI project using the wsdl from my service, my xml is expecting this:
当我使用我的服务中的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>
I need my service to accept requests with tns instead of not.
我需要我的服务接受tns的请求而不是。
I think I need to force the prefix, but I can't work out how to do this. I've found this link, which looks very complicated, but I'll try it next if there isn't an easier method: http://benscoderepo.blogspot.co.uk/2014/12/adding-soap-prefix-to-asmx-service.html
我想我需要强制使用前缀,但我无法弄清楚如何做到这一点。我发现这个链接看起来非常复杂,但如果没有更简单的方法,我会尝试下一步:http://benscoderepo.blogspot.co.uk/2014/12/adding-soap-prefix-到ASMX的service.html
Here's my asmx code:
这是我的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;
}
}
}
}
I changed
我变了
Use = SoapBindingUse.Literal
to
至
Use = SoapBindingUse.Default
It started working with the third party example. I switched it back to Literal and it still works. I'm mystified, but I'm glad everything has started working.
它开始使用第三方示例。我把它切换回Literal,它仍然有效。我很神秘,但我很高兴一切都开始奏效了。
1 个解决方案
#1
0
The problem was not the prefix. The problem was that the 3rd party was accidentally sending the wrong name space:
问题不是前缀。问题是第三方意外发送了错误的名称空间:
http://catmanager.com/schemas/catmanager/v8.8.0/notify
http://catmanager.com/schemas/catmanager/v8.8.0/notify
#1
0
The problem was not the prefix. The problem was that the 3rd party was accidentally sending the wrong name space:
问题不是前缀。问题是第三方意外发送了错误的名称空间:
http://catmanager.com/schemas/catmanager/v8.8.0/notify
http://catmanager.com/schemas/catmanager/v8.8.0/notify