如何使用 wsdl 文件从 SAP 导入数据以及如何使用从中生成的代理 class
How to Import Data from SAP using wsdl file and also how to consume the proxy class generated from it
谁能解释一下如何使用代理 class 因为我不明白,而且我在代理中有一个接口 class 我应该如何实现它来访问该方法在 IBinding
中描述
代理class生成的代码如下:
public interface IBinding {
/// <remarks/>
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://sap.com/xi/A1S/Global/QueryProjectIn/FindProjectByElementsRequest", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("ProjectByElementsResponse_sync", Namespace="http://sap.com/xi/SAPGlobal20/Global")]
ProjectByElementsResponseMessage_sync FindProjectByElements([System.Xml.Serialization.XmlElementAttribute(Namespace="http://sap.com/xi/SAPGlobal20/Global")] ProjectByElementsQueryMessage_sync ProjectByElementsQuery);
}
[HttpGet]
public static void Main()
{
ProjectByElementsQuerySelectionByElements query = new
ProjectByElementsQuerySelectionByElements();
ProjectByElementsQueryMessage_sync sync = new
ProjectByElementsQueryMessage_sync
{
ProjectSelectionByElements = query
};
}
这不是您访问 SAP 系统的方式,因为数据通常不会仅存储在一个 table 中,并且它会绕过应用程序框架中可用的任何授权检查。
因此,您应该寻找合适的 API,因为您可以在 API 中心找到它们。
创建网络引用的步骤:
Visual Studio -> 添加服务引用 -> 将 wsdl 文档路径粘贴到您的本地机器中 -> 单击 Go
服务将根据 wsdl 可见,通过单击服务名称可以看到相应的方法,然后在“高级”部分中有一个 Web 服务按钮可用,通过写入 Web 引用的名称进行 Web 引用然后单击按钮,Web 引用将自动添加到项目中。
实例化引用文件并访问方法
用于连接:
using webreference;
var service = new service();
service.Credentials = new System.Net.NetworkCredential("username", "password");
service.Url = "https://" + xxx.com";
谁能解释一下如何使用代理 class 因为我不明白,而且我在代理中有一个接口 class 我应该如何实现它来访问该方法在 IBinding
中描述代理class生成的代码如下:
public interface IBinding {
/// <remarks/>
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://sap.com/xi/A1S/Global/QueryProjectIn/FindProjectByElementsRequest", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("ProjectByElementsResponse_sync", Namespace="http://sap.com/xi/SAPGlobal20/Global")]
ProjectByElementsResponseMessage_sync FindProjectByElements([System.Xml.Serialization.XmlElementAttribute(Namespace="http://sap.com/xi/SAPGlobal20/Global")] ProjectByElementsQueryMessage_sync ProjectByElementsQuery);
}
[HttpGet]
public static void Main()
{
ProjectByElementsQuerySelectionByElements query = new
ProjectByElementsQuerySelectionByElements();
ProjectByElementsQueryMessage_sync sync = new
ProjectByElementsQueryMessage_sync
{
ProjectSelectionByElements = query
};
}
这不是您访问 SAP 系统的方式,因为数据通常不会仅存储在一个 table 中,并且它会绕过应用程序框架中可用的任何授权检查。 因此,您应该寻找合适的 API,因为您可以在 API 中心找到它们。
创建网络引用的步骤: Visual Studio -> 添加服务引用 -> 将 wsdl 文档路径粘贴到您的本地机器中 -> 单击 Go
服务将根据 wsdl 可见,通过单击服务名称可以看到相应的方法,然后在“高级”部分中有一个 Web 服务按钮可用,通过写入 Web 引用的名称进行 Web 引用然后单击按钮,Web 引用将自动添加到项目中。
实例化引用文件并访问方法 用于连接:
using webreference;
var service = new service();
service.Credentials = new System.Net.NetworkCredential("username", "password");
service.Url = "https://" + xxx.com";