Forum Xamarin.Forms

Xamarin.Forms consum SOAP web service on android procect

Hi,
i want to consum a soap web service with xamarin forms on adroid. I use VS2019, .netstandard 2.0 and Xamarin 16.3.0.278. I generated a web reference and in created reference.cs the important code is:

[System.Web.Services.Protocols.SoapHeaderAttribute("Activation")]
[System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestElementName="report.bundle.operation", RequestNamespace="example.com/webService", ResponseElementName="report.bundle.operationResponse", ResponseNamespace="example.com/webService", Use=System.Web.Services.Description.SoapBindingUse.Literal)]
[return: System.Xml.Serialization.XmlElementAttribute("report.bundle.operationResponse")]
public reportbundleoperationResponseType reportbundleoperation([System.Xml.Serialization.XmlElementAttribute("report.bundle.operationRequest")] reportbundleoperationRequestType reportbundleoperationRequest) {
object[] results = this.Invoke("reportbundleoperation", new object[] {
reportbundleoperationRequest});
return ((reportbundleoperationResponseType)(results[0]));
}
The used wsdl file show me the follow code part for my funktion:

wsdl:operation name="report.bundle.operation"
wsdl:input message="bo:report.bundle.operationRequest"
wsdl:output message="bo:report.bundle.operationResponse"
wsdl:fault message="bo:Result" name="FaultName"
wsdl:operation
Then i call the method reportbundleoperation from my code. When i call the method from a windows forms project with .net 4.7 the web service works fine, but wenn i try to call the method from my xamarin forms project the service is connectet but i get an error "UnknownMethod: Method 'reportbundleoperation' is unknown in Object 'WebService' every time.

Then i watched the outgoing traffic with fiddler and it showed me follow:

soap:Body soap:encodingStyle="schemas.xmlsoap.org/soap/encoding
q1:reportbundleoperation xmlns:q1="example.com/webService"
reportbundleoperationRequest href="#id1"
q1:reportbundleoperation
The outgoing call try to call the method with name reportbundleoperation in place of report.bundle.operation

I think, the problem is the part [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestElementName="report.bundle.operation" .... .
I call the method with the name reportbundleoperation and in the web service the method named report.bundle.operation. I think the RequestElementName should transfer the name reportbundleoperation to report.bundle.operation .. isn't it?

Can sombody help me, can sombody tell me, if there is a bug in the .netstandard or in mono?

with best reguards

MH

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    I have never been able to add a web reference directly to XF project.

    Try to add it to Xamarin Android prj and call it using DependencyServices

  • hemawsthemawst Member ✭✭

    Hi, thanks for your fast answer. Sorry for my unclear question. I had add the web reference directly to my android project and i use DependencyServices. This all works very fine. I think the problem is, the method names in the web service contains dots like "report.bundle.operation". I call the method with this.Invoke("reportbundleoperation") from my reference.cs. So i think, the attribute System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestElementName="report.bundle.operation" ... should translate the called name reportbundleoperation to the real name at web service report.bundle.operation. And i think this translation not work in .net standard 2.0. Fiddler
    Unfortunately the web service is not my own and i can't rename the methods.

  • JarvanJarvan Member, Xamarin Team Xamurai
  • hemawsthemawst Member ✭✭
    edited November 2019

    That would be my last option. But i dont't want to do it that way.
    The question is, have the Microsoft\Framework\MonoAndroid\v1.0\System.Web.Services.dll, that is used by xamarin,
    a problem with soap function names
    ( like wsdl:operation name="report.bundle.operation" )
    if the function name in web service has a dot?

    The .netFramework 4.7 \Microsoft\Framework.NETFramework\v4.7\System.Web.Services.dll seems to managed it correctly.

  • NMackayNMackay GBInsider, University admin

    SOAP :s:(

  • NMackayNMackay GBInsider, University admin

    If it's a WCF service you can expose a Restful endpoint.

  • thisismyselfthisismyself Member ✭✭

    We solved the issue as follow...

    1. Created an extra library (.NET Standard 2.0) where all our WCF / SOAP related code is in
    2. Reference this library from the Xamarin.Forms project
    3. The colleague who did it used a quite old svcutil.exe from silverlight to generate the code from the WSDL. Why he did this, I do not remember, I think there were some incompatibilites.
    4. In our extra library, we mapped all the SOAP related data type we need in XF project to Business Objects, so no SOAP related classes are leaving this extra library
  • hemawsthemawst Member ✭✭

    Thank you for the answers.
    This problem seems to be not easy to fix.
    @NMackay The web service is not WFC, it was written in java JAX-WS.
    Unfortunately the web service is not my own and i can't edit or change the service but i have to use it.
    The System.Web.Services.dll from mono seems to be comparatively old and I can not hope that it will be improved.

    Can I use the Web.Services.dll from .NetFramework in any way or are they totally uncompatible?
    I have already made experiments with svcutil.exe, but unfortunately unsuccessful. Which version should I use there?

Sign In or Register to comment.