Invoking a Java/AXIS Web Service from .NET: the ‘return null’ issue

后端 未结 1 1621
逝去的感伤
逝去的感伤 2021-02-08 10:44

I\'ve been seeking for this problem through all google, stackoverflow and more. And I found a lot of related answers to it, but not a real solution.

I\'m consuming an A

1条回答
  •  深忆病人
    2021-02-08 11:34

    Finally I solved this problem, a friend of mine helped me, apparently there were problems with the WSDL and the namespaces. C# generated the proxy wrong. Don't know if it's a c# problem or axis problem. But hope this answer helps anyone else. Take a look to all the namespaces on the methods of the WebService. C# Generated a method like this.

    /// 
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.openuri.org/InformacionPoliza", RequestNamespace = "http://www.openuri.org/", ResponseNamespace = "http://www.openuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
            [return: System.Xml.Serialization.XmlElementAttribute("Poliza")]
            public Poliza InformacionPoliza(CriteriosPoliza CriteriosPoliza)
            {
                object[] results = this.Invoke("InformacionPoliza", new object[] {
                        CriteriosPoliza});
                return ((Poliza)(results[0]));
            }
    

    But in the WSDL had something like this..

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ****
    
    
    
    
    

    Look at the it refers to the tns2 namespace and it says xmlns:tns2="http://www.example.org/PolizasBanorteSchema"

    So the generated proxy by .NET was wrong it had to be like this

    /// 
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.openuri.org/InformacionPoliza", RequestNamespace = "http://www.openuri.org/", ResponseNamespace = "http://www.openuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
            [return: System.Xml.Serialization.XmlElementAttribute("Poliza", Namespace = "http://www.example.org/PolizasBanorteSchema")]
            public Poliza InformacionPoliza(CriteriosPoliza CriteriosPoliza)
            {
                object[] results = this.Invoke("InformacionPoliza", new object[] {
                        CriteriosPoliza});
                return ((Poliza)(results[0]));
            }
    

    The namespace did the magic,

      [return: System.Xml.Serialization.XmlElementAttribute("Poliza", Namespace = "http://www.example.org/PolizasBanorteSchema")]
    

    Changed that line of code and everything worked like a charm So, be careful when using arrays and diferent namespaces in an axis service, you may have some problems generating a c# client.

    This post was right :)

    0 讨论(0)
提交回复
热议问题