Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 WCF客户端出现问题(对于非.Net服务)_C# 4.0_Wcf Client - Fatal编程技术网

C# 4.0 WCF客户端出现问题(对于非.Net服务)

C# 4.0 WCF客户端出现问题(对于非.Net服务),c#-4.0,wcf-client,C# 4.0,Wcf Client,在c#项目中,我必须查询一些不是用.Net构建的web服务(实际上是WebLogic) 在我可以毫无问题地查询大多数web服务的地方,我很难找到一个。调用该方法时,会出现以下错误(堆栈跟踪已删除): 通过谷歌搜索,我得出结论,这是由于远程服务有两种方法FirstMethod和SecondMethod,这两种方法都有一个复杂的FirstMethodRequest类型,其输入参数为属性“In”。但是,In参数有两种不同的类型(分别是firstMethodInType和secondMethodInTy

在c#项目中,我必须查询一些不是用.Net构建的web服务(实际上是WebLogic)

在我可以毫无问题地查询大多数web服务的地方,我很难找到一个。调用该方法时,会出现以下错误(堆栈跟踪已删除):

通过谷歌搜索,我得出结论,这是由于远程服务有两种方法
FirstMethod
SecondMethod
,这两种方法都有一个复杂的
FirstMethodRequest
类型,其输入参数为属性“In”。但是,In参数有两种不同的类型(分别是
firstMethodInType
secondMethodInType

我用于构建代理代码。这实际上生成了代码:

伪代码:

class firstMethodRequest
{
    public firstMethodintype @in; // First occurence of a "in" parameter
}

class firstMethodintype
{
}

class secondMethodRequest
{
    public secondMethodintype @in; // Second occurence of a "in" parameter
}

class secondMethodintype
{
}
完整代码:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.MessageContractAttribute(WrapperName="first-method", WrapperNamespace="http://mynamespace/ws/wsdl/first-method", IsWrapped=true)]
internal partial class firstMethodRequest
{
    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
    public firstMethodintype @in;

    public firstMethodRequest()        {        }
    public firstMethodRequest(firstMethodintype @in)        {            this.@in = @in;        }
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(TypeName="first-method-in-type", Namespace="http://mynamespace")]
public partial class firstMethodintype
{
    private string site_origineField;
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.MessageContractAttribute(WrapperName="second-method", WrapperNamespace="http://mynamespace/ws/wsdl/second-method", IsWrapped=true)]
internal partial class secondMethodRequest
{
    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
    public secondMethodintype @in; // Problem is here

    public secondMethodRequest()        {        }
    public secondMethodRequest(secondMethodintype @in)        {            this.@in = @in;        }
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(TypeName="second-method-in-type", Namespace="http://mynamespace")]
public partial class secondMethodintype
{
    private string site_origineField;
}
由于我不能控制输出代码,如何才能正确地解决我的问题

提前thx

[Edit]不知道它是否相关,但这里是WSDL定义的摘录:

<message name="first-method-in">
    <part name="in" type="tp:first-method-in-type"/>
</message>
<message name="second-method-in">
    <part name="in" type="tp:second-method-in-type"/>
</message>

[Edit 2]此外,如果源WSDL/Schema无效或不符合W3C标准,请告诉我。我可以与客户协商重写其WS

[Edit 3]如果我手动将wsdl修补到(重命名为第二部分):



然后问题消失了(当然对第二个方法的调用停止了)

最后,我要求客户更改其WSDL以避免此名称冲突。
这解决了问题,可能是解决问题的最简单方法。

最后,我要求客户更改其WSDL以避免此名称冲突。 这解决了问题,可能是解决问题的最简单方法

<message name="first-method-in">
    <part name="in" type="tp:first-method-in-type"/>
</message>
<message name="second-method-in">
    <part name="in" type="tp:second-method-in-type"/>
</message>
<message name="first-method-in">
    <part name="in" type="tp:first-method-in-type"/>
</message>
<message name="second-method-in">
    <part name="inSecond" type="tp:second-method-in-type"/>
</message>