2009-04-09 9 views
2

J'ai un problème avec la consommation d'un service Web tiers dans .NET C#. Il fonctionne sur Apache (NuSoap). Tout fonctionne normalement jusqu'à la désérialisation (probablement ...). Lorsque j'appelle la fonction SoapHttpClientProtocol.Invoke(), j'obtiens toujours un tableau d'objets avec un objet nul. La mauvaise est que ce service Web ne fournit pas un document WSDL. ?. :-(Service Web PHP en C#: La fonction Invoke() renvoie la valeur null

Quelqu'un peut-il me aider, s'il vous plaît, je pense, que le processus de désérialisation ne fonctionne pas

Voici la réponse de savon:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> 
    <SOAP-ENV:Body> 
    <ns1:EncodingTestResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"> 

     <item xmlns:ns4071="http://xml.apache.org/xml-soap" xsi:type="ns4071:Map"> 
     <item> 
      <key xsi:type="xsd:string">ascii</key> 
      <value xsi:type="xsd:string">ertzyuuioasdcnERSTZYUIOADCN</value> 
     </item> 
     <item> 
      <key xsi:type="xsd:string">latin2</key> 
      <value xsi:type="xsd:string">xy</value> 
     </item> 
     <item> 
      <key xsi:type="xsd:string">w1250</key> 
      <value xsi:type="xsd:string">pq</value> 
     </item> 
     </item> 

    </ns1:EncodingTestResponse> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

méthode d'appel:

[SoapTrace] 
[SoapDocumentMethod("EncodingTest",ParameterStyle=SoapParameterStyle.Wrapped)] 
public item EncodingTest() 
{ 
    var obj = this.Invoke("EncodingTest", new object[] {}); 
    return null; 
} 

et l'objet, que j'essayais de désérialiser:

[Serializable] 
[XmlType(Namespace = "http://xml.apache.org/xml-soap", TypeName="item")] 
public class item 
{ 
    [XmlArray("item", Form = XmlSchemaForm.Unqualified)] 
    public item[] items { get; set; } 

    [XmlElement(Form=XmlSchemaForm.Unqualified)] 
    public string key { get; set; } 

    [XmlElement(Form = XmlSchemaForm.Unqualified)] 
    public string value { get; set; } 
} 
+0

~ Je me demande si vous pourriez m'aider, je pense que j'ai un problème similaire. Est-ce que le code que vous avez laissé dans la réponse du bas est vraiment tout ce que vous avez fait pour résoudre ce problème? – jcolebrand

Répondre

4

Je résous cela, mais ce n'était pas facile. Au moins j'ai appris à contrôler la désérialisation xml .. :)

[SoapDocumentMethod(ResponseElementName = "EncodingTestResponse", ResponseNamespace = "http://schemas.xmlsoap.org/soap/envelope/")] 
[return: XmlArray("item", Namespace = "", IsNullable = false)] 
[SoapTrace] 
public item[] EncodingTest() 
{ 
    object[] result = this.Invoke("EncodingTest", new object[] { }); 
    return (item[])result[0]; 
} 


[SoapType(TypeName = "Map", Namespace = "http://xml.apache.org/xml-soap")] 
    public class item 
    { 
     [XmlElement(Form = XmlSchemaForm.Unqualified)] 
     public string key { get; set; } 

     [XmlElement(Form = XmlSchemaForm.Unqualified)] 
     public string value { get; set; } 

     public item[] items { get; set; } 
    } 
Questions connexes