Last post Dec 18, 2019 04:30 PM by bruce (sqlwork.com)
Participant
1246 Points
564 Posts
Dec 18, 2019 03:30 AM|nideeshm|LINK
I need to call asmx bassssed webservice from my project.
I have added web reference to my project.
The soap body in wsdl looks like below. The tag under <soap:body> is same as method name
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <method1> <property1>string</property1> <property2>string</property2> </method1> </soap:Body> </soap:Envelope>
After generating the proxy class, i was expecting a class "method1" inside the main proxy class named "webrefernce.cs"
Instead the proxy class have no such sub class and the invocation method is directly using strings as input
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://namespace/method1, RequestNamespace="http://namespace", ResponseNamespace="http://namespace", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public string Cmethod(string Property1, string Property2) { object[] results = this.Invoke("method1", new object[] { Property1, Property2}); return ((string)(results[0])); }
Instead i was expecting something like below, which is working correctly in another project. It has class called "MethodRequest"
[System.Web.Services.Protocols.SoapHeaderAttribute("OGHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.InOut)] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://namespace.wsdl#Method1", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)] [return: System.Xml.Serialization.XmlElementAttribute("MethodResponse", Namespace="http://webservices.micros.com/ows/5.1/Reservation.wsdl")] public MethodResponse Method1([System.Xml.Serialization.XmlElementAttribute(Namespace="http://webservices.micros.com/ows/5.1/Reservation.wsdl")] MethodRequest methodRequest ) { object[] results = this.Invoke("Method1", new object[] { methodRequest }); return ((MethodResponse)(results[0])); }
Is there any advanced setting while generating the proxy class , to generate class for the request types? Is it some wsdl setting
All-Star
58144 Points
15646 Posts
Dec 18, 2019 04:30 PM|bruce (sqlwork.com)|LINK
your sample is a soap body, not a wsdl. the matching wsdl would define two string parameters to the method, rather than a complex type with properties.
if you look at the wsdl file (http://webservices.micros.com/ows/5.1/Reservation.wsdl) for the second case, you will see it defines complex elements for the parameters.
Participant
1246 Points
564 Posts
Creating proxy class of webservice for .net core
Dec 18, 2019 03:30 AM|nideeshm|LINK
I need to call asmx bassssed webservice from my project.
I have added web reference to my project.
The soap body in wsdl looks like below. The tag under <soap:body> is same as method name
After generating the proxy class, i was expecting a class "method1" inside the main proxy class named "webrefernce.cs"
Instead the proxy class have no such sub class and the invocation method is directly using strings as input
Instead i was expecting something like below, which is working correctly in another project. It has class called "MethodRequest"
Is there any advanced setting while generating the proxy class , to generate class for the request types? Is it some wsdl setting
Nideesh.S
Mark as answer, If it helps you.
All-Star
58144 Points
15646 Posts
Re: Creating proxy class of webservice for .net core
Dec 18, 2019 04:30 PM|bruce (sqlwork.com)|LINK
your sample is a soap body, not a wsdl. the matching wsdl would define two string parameters to the method, rather than a complex type with properties.
if you look at the wsdl file (http://webservices.micros.com/ows/5.1/Reservation.wsdl) for the second case, you will see it defines complex elements for the parameters.