WSDL到C#代理生成方法而不是预期的类

时间:2017-06-23 12:26:52

标签: c# visual-studio web-services proxy wsdl

当我从WSDL文件生成代理时(通过添加Web服务引用),Visual Studio生成类而不是方法。 我在Eclipse中尝试了同样的事情,并且正确生成了代理。 我使用的是Visual Studio 2013。

WSDL:

...
   <xs:element name='getAttribut' type='tns:getAttribut'/>
   <xs:element name='getAttributResponse' type='tns:getAttributResponse'/>
...
<xs:complexType name='getAttribut'>
    <xs:sequence>
     <xs:element minOccurs='0' name='id' type='xs:string'/>
     <xs:element minOccurs='0' name='attributName' type='xs:string'/>
    </xs:sequence>
   </xs:complexType>
   <xs:complexType name='getAttributResponse'>
    <xs:sequence>
     <xs:element maxOccurs='unbounded' minOccurs='0' name='return' type='xs:string'/>
    </xs:sequence>
   </xs:complexType>
...
 <message name='LdapWsAuth_getAttribut'>
  <part element='tns:getAttribut' name='getAttribut'></part>
 </message>
 <message name='LdapWsAuth_getAttributResponse'>
  <part element='tns:getAttributResponse' name='getAttributResponse'></part>
 </message>
...
  <operation name='getAttribut' parameterOrder='getAttribut'>
   <input message='tns:LdapWsAuth_getAttribut'></input>
   <output message='tns:LdapWsAuth_getAttributResponse'></output>
   <fault message='tns:LdapWsException' name='LdapWsException'></fault>
  </operation>

JAVA:

  public java.lang.String[] getAttribut(java.lang.String id, java.lang.String attributName) throws java.rmi.RemoteException, LdapWsException{
    if (ldapWsAuth_PortType == null)
      _initLdapWsAuthProxy();
    return ldapWsAuth_PortType.getAttribut(id, attributName);
  }

c#:

public partial class getAttribute : object, System.ComponentModel.INotifyPropertyChanged {

    private string idField;

    private string attributNameField;
       [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string id {
        get {
            return this.idField;
        }
        set {
            this.idField = value;
            this.RaisePropertyChanged("id");
        }
    }
   [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string attributName {
        get {
            return this.attributNameField;
        }
        set {
            this.attributNameField = value;
            this.RaisePropertyChanged("attributName");
        }
    }

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged(string propertyName) {
        System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
        if ((propertyChanged != null)) {
            propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
    }
}

    public string[] getAttribute([System.Xml.Serialization.XmlElementAttribute("getAttribute", Namespace="http://.../")] getAttribute getAttribute1) {
        object[] results = this.Invoke("getAttribute", new object[] {
                    getAttribute1});
        return ((string[])(results[0]));
    }

我也尝试过使用wsdl.exe工具,我得到了同样的东西。

是否有可能使.Net的生成方式与Java相同?

如果您需要更多信息,请告诉我。

0 个答案:

没有答案