2011-08-03 9 views
1

から最初の結果を得ることができます。だけ私はPerlのSOAPサービスを消費しようとしているperlのSOAPサービス

=begin WSDL 

_IN nr $string hah 
_RETURN @string hih 

=cut 

ので、perlは一つの引数を取り、結果の配列を返す:

http://img29.imageshack.us/img29/1898/sniffer.png

<?xml version="1.0" encoding="UTF-8"?> 
<!-- WSDL for http://10.0.252.24/VM created by Pod::WSDL version: 0.061 on Wed Aug 3 10:05:50 2011 --> 
<wsdl:definitions targetNamespace="http://10.0.252.24/VM" xmlns:impl="http://10.0.252.24/VM" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://10.0.252.24/VM"> 

     <wsdl:types> 
       <schema targetNamespace="http://10.0.252.24/VM" xmlns="http://www.w3.org/2001/XMLSchema"> 
         <import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> 
         <complexType name="ArrayOfString"> 
           <complexContent> 
             <restriction base="soapenc:Array"> 
               <attribute ref="soapenc:arrayType" wsdl:arrayType="soapenc:string[]" /> 
             </restriction> 
           </complexContent> 
         </complexType> 
       </schema> 
     </wsdl:types> 

     <wsdl:message name="VMsRequest"> 
       <wsdl:part name="nr" type="xsd:string"> 
         <wsdl:documentation>hah</wsdl:documentation> 
       </wsdl:part> 
     </wsdl:message> 

     <wsdl:message name="VMsResponse"> 
       <wsdl:part name="VMsReturn" type="tns1:ArrayOfString"> 
         <wsdl:documentation>hih</wsdl:documentation> 
       </wsdl:part> 
     </wsdl:message> 

     <wsdl:portType name="VMHandler"> 
       <wsdl:operation name="VMs" parameterOrder="nr"> 
         <wsdl:input message="impl:VMsRequest" name="VMsRequest" /> 
         <wsdl:output message="impl:VMsResponse" name="VMsResponse" /> 
       </wsdl:operation> 

     </wsdl:portType> 

     <wsdl:binding name="VMSoapBinding" type="impl:VMHandler"> 
       <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> 

       <wsdl:operation name="VMs"> 
         <wsdlsoap:operation soapAction="" /> 
         <wsdl:input name="VMsRequest"> 
           <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.0.252.24/VM" use="encoded" /> 
         </wsdl:input> 
         <wsdl:output name="VMsResponse"> 
           <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.0.252.24/VM" use="encoded" /> 
         </wsdl:output> 
       </wsdl:operation> 

     </wsdl:binding> 

     <wsdl:service name="VMHandlerService"> 
       <wsdl:port binding="impl:VMSoapBinding" name="VM"> 
         <wsdlsoap:address location="http://10.0.252.24/VM" /> 
       </wsdl:port> 
     </wsdl:service> 

</wsdl:definitions> 

WSDLは、次のようになります(フルサイズの画像を表示します)

とC#のようになります。テストのとき

using System; 
using System.ComponentModel; 
using System.Diagnostics; 
using System.Web.Services; 
using System.Web.Services.Protocols; 
using System.Xml.Serialization; 


[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] 
[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.ComponentModel.DesignerCategoryAttribute("code")] 
[System.Web.Services.WebServiceBindingAttribute(Name="VMSoapBinding", Namespace="http://10.0.252.24/VM")] 
public partial class VMHandlerService : System.Web.Services.Protocols.SoapHttpClientProtocol { 

    private System.Threading.SendOrPostCallback VMsOperationCompleted; 

    public VMHandlerService() { 
     this.Url = "http://10.0.252.24/VM"; 
    } 

    public event VMsCompletedEventHandler VMsCompleted; 

    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://10.0.252.24/VM", ResponseNamespace="http://10.0.252.24/VM")] 
    [return: System.Xml.Serialization.SoapElementAttribute("VMsReturn")] 
    public string[] VMs(string nr) { 
     object[] results = this.Invoke("VMs", new object[] { 
        nr}); 
     return ((string[])(results[0])); 
    } 

    public System.IAsyncResult BeginVMs(string nr, System.AsyncCallback callback, object asyncState) { 
     return this.BeginInvoke("VMs", new object[] { 
        nr}, callback, asyncState); 
    } 

    public string[] EndVMs(System.IAsyncResult asyncResult) { 
     object[] results = this.EndInvoke(asyncResult); 
     return ((string[])(results[0])); 
    } 

    public void VMsAsync(string nr) { 
     this.VMsAsync(nr, null); 
    } 

    public void VMsAsync(string nr, object userState) { 
     if ((this.VMsOperationCompleted == null)) { 
      this.VMsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnVMsOperationCompleted); 
     } 
     this.InvokeAsync("VMs", new object[] { 
        nr}, this.VMsOperationCompleted, userState); 
    } 

    private void OnVMsOperationCompleted(object arg) { 
     if ((this.VMsCompleted != null)) { 
      System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); 
      this.VMsCompleted(this, new VMsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); 
     } 
    } 

    public new void CancelAsync(object userState) { 
     base.CancelAsync(userState); 
    } 
} 

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] 
public delegate void VMsCompletedEventHandler(object sender, VMsCompletedEventArgs e); 

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] 
[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.ComponentModel.DesignerCategoryAttribute("code")] 
public partial class VMsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { 

    private object[] results; 

    internal VMsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
      base(exception, cancelled, userState) { 
     this.results = results; 
    } 

    /// <remarks/> 
    public string[] Result { 
     get { 
      this.RaiseExceptionIfNecessary(); 
      return ((string[])(this.results[0])); 
     } 
    } 
} 

cannot convert string to string[]

string[] test = kk.VMs("35294000"); 

私は例外を取得。 コードを変更します:

[System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace = "http://10.0.252.24/VM", ResponseNamespace = "http://10.0.252.24/VM")] 
    [return: System.Xml.Serialization.SoapElementAttribute("VMsReturn")] 
    public string VMs(string nr) { 
     object[] results = this.Invoke("VMs", new object[] { 
        nr}); 
     return ((string)(results[0])); 
    } 

and 
string test = kk.VMs("35294000"); 

これで結果が返されます。 しかし、最初の結果と私は配列を取得する必要があります。

+0

解決済み。 soap :: liteの "機能"でした。 の代わりに、あなたがする必要がある @result リターン(これは代わりに、結果の配列のパラメータを持つ間違った石鹸の答えを返します) で配列を返す:石鹸アレイと今ではすべてを返します @result リターン\自動的に生成されたwsdlコードでそのまま動作します。 – Anders

+1

解決策として答えを提出してください。 – Axeman

答えて

0

解決済み。 soap :: liteの "機能"でした。 の代わりに、あなたがする必要がある (これは代わりに、結果の配列のパラメータを持つ間違った石鹸の答えを返します)

return @result 

で配列を返す:

今石鹸配列を返します
return \@result 

全てが自動的に生成されたwsdlコードで動作します。

関連する問題