【发布时间】:2019-12-23 11:46:44
【问题描述】:
我已经使用 c# 制作了自己的 asmx 网络服务。我的主课是这样的
[WebService(Namespace = "my.namespace")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[SoapDocumentService(SoapBindingUse.Literal, SoapParameterStyle.Bare, RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
public class ICService : System.Web.Services.WebService
{
[WebMethod()]
public ProductListResponse GetProductList(ProductListRequest ProductListRequest) { ... }
}
如果我在网络上查看此方法的 xml 请求,结果如下:
<soap:Body>
<ProductListRequest xmlns="my.namespace">
. . .
</ProductListRequest>
</soap:Body>
一切都很好,但是当我在任何其他项目中添加对此 WS 的引用时,我需要额外的方法调用类。不是什么大问题,但我想知道为什么会这样。
调用示例:
GetProductListResponse resp = client.GetProductList(new GetProductListRequest
{
ProductListRequest = new ProductListRequest { }
});
这个 GetProductListRequest 类从何而来? Anwser 似乎有额外的类:GetProductListResponse.GetProductListResult.Products 而不仅仅是 ProductListResponse.Products。
我使用过许多其他网络服务,但这种行为对我来说是新的。
【问题讨论】:
标签: c# .net web-services soap asmx