询问者
implementar y consumir un .wsdl de sap en c#

问题
-
Buenas Tardes, Necesito ayuda por favor.
el caso es el siguiente, tengo un wsdl(link) y necesito implementarlo y consumirlo el tema es que no tengo casi nada de expiencia con este tema y opto a su ayuda de alguna persona que quiera ayudarme.
estoy usando el software soapui para probar el wsdl y funciona correctamente
me gustaria saber como puedo hacer lo mismo con c# enviar los datos que aparecen en pantalla y que el wsdl me conteste.
desde ya muchas gracias.
全部回复
-
hola
>>me gustaria saber como puedo hacer lo mismo con c# enviar los datos que aparecen en pantalla y que el wsdl me conteste.
Si es un wsdl tienes que crear una web reference, pero ojo una web reference no una service reference, ya que esta ultima es para servicio de WCF
si creas el proxy podras invocarlo
quizas debas usar la opcion de la imagen, depende de cual verison de visual studio estes usando
saludos
Leandro Tuttini
Blog
MVP Profile
Buenos Aires
Argentina -
me genero este codigo estimado.
//------------------------------------------------------------------------------
// <auto-generated>
// Este código fue generado por una herramienta.
// Versión de runtime:4.0.30319.42000
//
// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
// se vuelve a generar el código.
// </auto-generated>
//------------------------------------------------------------------------------
//
// Microsoft.VSDesigner generó automáticamente este código fuente, versión=4.0.30319.42000.
//
#pragma warning disable 1591
namespace WSAquaChile.balanzasap {
using System;
using System.Web.Services;
using System.Diagnostics;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
using System.ComponentModel;
/// <remarks/>
// CODEGEN: No se controló el elemento de extensión WSDL opcional 'Policy' del espacio de nombres 'http://schemas.xmlsoap.org/ws/2004/09/policy'.
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.7.3056.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="ZWS_TEST_soap12", Namespace="urn:sap-com:document:sap:soap:functions:mc-style")]
public partial class ZWS_TEST : System.Web.Services.Protocols.SoapHttpClientProtocol {
private System.Threading.SendOrPostCallback ZppwsTestOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <remarks/>
public ZWS_TEST() {
this.SoapVersion = System.Web.Services.Protocols.SoapProtocolVersion.Soap12;
this.Url = global::WSAquaChile.Properties.Settings.Default.WSAquaChile_balanzasap_ZWS_TEST;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
}
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
}
}
/// <remarks/>
public event ZppwsTestCompletedEventHandler ZppwsTestCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:sap-com:document:sap:soap:functions:mc-style:ZPPWS_TEST:ZppwsTestRequest", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("ZppwsTestResponse", Namespace="urn:sap-com:document:sap:soap:functions:mc-style")]
public ZppwsTestResponse ZppwsTest([System.Xml.Serialization.XmlElementAttribute("ZppwsTest", Namespace="urn:sap-com:document:sap:soap:functions:mc-style")] ZppwsTest ZppwsTest1) {
object[] results = this.Invoke("ZppwsTest", new object[] {
ZppwsTest1});
return ((ZppwsTestResponse)(results[0]));
}
/// <remarks/>
public void ZppwsTestAsync(ZppwsTest ZppwsTest1) {
this.ZppwsTestAsync(ZppwsTest1, null);
}
/// <remarks/>
public void ZppwsTestAsync(ZppwsTest ZppwsTest1, object userState) {
if ((this.ZppwsTestOperationCompleted == null)) {
this.ZppwsTestOperationCompleted = new System.Threading.SendOrPostCallback(this.OnZppwsTestOperationCompleted);
}
this.InvokeAsync("ZppwsTest", new object[] {
ZppwsTest1}, this.ZppwsTestOperationCompleted, userState);
}
private void OnZppwsTestOperationCompleted(object arg) {
if ((this.ZppwsTestCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.ZppwsTestCompleted(this, new ZppwsTestCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
}
private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
}
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
}
return false;
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:sap-com:document:sap:soap:functions:mc-style")]
public partial class ZppwsTest {
private ZppsTest[] itOrdenField;
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
[System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
public ZppsTest[] ItOrden {
get {
return this.itOrdenField;
}
set {
this.itOrdenField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:sap-com:document:sap:soap:functions:mc-style")]
public partial class ZppsTest {
private string aufnrField;
private string plnbezField;
private string maktxField;
private string kdaufField;
private string plnmeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Aufnr {
get {
return this.aufnrField;
}
set {
this.aufnrField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Plnbez {
get {
return this.plnbezField;
}
set {
this.plnbezField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Maktx {
get {
return this.maktxField;
}
set {
this.maktxField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Kdauf {
get {
return this.kdaufField;
}
set {
this.kdaufField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Plnme {
get {
return this.plnmeField;
}
set {
this.plnmeField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:sap-com:document:sap:soap:functions:mc-style")]
public partial class ZppwsTestResponse {
private string exMsgField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string ExMsg {
get {
return this.exMsgField;
}
set {
this.exMsgField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.7.3056.0")]
public delegate void ZppwsTestCompletedEventHandler(object sender, ZppwsTestCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.7.3056.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class ZppwsTestCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal ZppwsTestCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <remarks/>
public ZppwsTestResponse Result {
get {
this.RaiseExceptionIfNecessary();
return ((ZppwsTestResponse)(this.results[0]));
}
}
}
}
#pragma warning restore 1591