Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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
Wcf svcutil用于多个WSDL和唯一XSD文件?_Wcf_Wsdl_Svcutil.exe - Fatal编程技术网

Wcf svcutil用于多个WSDL和唯一XSD文件?

Wcf svcutil用于多个WSDL和唯一XSD文件?,wcf,wsdl,svcutil.exe,Wcf,Wsdl,Svcutil.exe,我想从WCF客户端使用一些(非.Net)web服务 我有所有这些服务的WSDL文件。每一个引用定义所有类型的相同XSD文件 在这种情况下,我不知道如何正确处理svcuti.exe 如果我跑步: svcutil.exe WS1.wsdl types.xsd svcutil.exe ws1.wsdl types.xsd svcutil.exe ws2.wsdl types.xsd 它工作得很好 如果我运行以下操作之一,它将失败: svcutil.exe*.wsdl types.xsd svcuti

我想从WCF客户端使用一些(非.Net)web服务

我有所有这些服务的WSDL文件。每一个引用定义所有类型的相同XSD文件

在这种情况下,我不知道如何正确处理svcuti.exe

如果我跑步:

svcutil.exe WS1.wsdl types.xsd

svcutil.exe ws1.wsdl types.xsd
svcutil.exe ws2.wsdl types.xsd
它工作得很好

如果我运行以下操作之一,它将失败:

svcutil.exe*.wsdl types.xsd

svcutil.exe ws1.wsdl types.xsd
svcutil.exe ws2.wsdl types.xsd
svcutil.exe ws1.wsdl ws2.wsdl types.xsd

svcutil.exe ws1.wsdl types.xsd
svcutil.exe ws2.wsdl types.xsd
(这一条适用于两行,但当我编译时,类型会被定义多次)

由于每个服务使用相同的结果类型,我不想重复代码(即我不能为所有服务使用不同的“结果”类型)

我有什么选择? 我正在为这个简单的案子挣扎

提前thx

[编辑]我的问题的可能原因之一是所有服务都定义了相同的端口名:

<service name="service 1">
    <port name="lbWebPort" binding="y:lbWebBinding">
        <soap:address location="xxx"/>
    </port>
</service>
...
<service name="service 2">
    <port name="lbWebPort" binding="y:lbWebBinding">
        <soap:address location="xxx"/>
    </port>
</service>

...

我终于能够使用一个糟糕的powershell脚本解除所有内容

关键思想是为所有服务指定一个自定义名称空间。 但由于某些部分(返回类型)在所有服务中共享,我不得不从XSD中提取类型并引用它。过程是这样的:

  • 如果需要,下载最新的wsdl文件
  • 设置工具的路径
  • 根据xsd文件中定义的类型创建cs文件
  • 在临时dll中编译此cs文件
  • 对于每个服务,使用svcutil创建代理。注意“共享”公共类型所需的
    /r:Temp.dll
  • 删除temp.dll文件

        $web = new-object System.Net.WebClient
    $currDir = (get-item WSDefinition).FullName
    
    if($false) // Set to true if wsdl changed
    {
        $web.DownloadFile("http://urlofmywebservice/majClient/lbWebPort?wsdl","$currDir\CustomerServiceMajClientImpl.wsdl")
        $web.DownloadFile("http://urlofmywebservice/lotClient/lbWebPort?wsdl","$currDir\CustomerServiceLotClientImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/interlocuteur/lbWebPort?wsdl","$currDir\CustomerServiceInterlocuteursImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/cdeConf/lbWebPort?wsdl","$currDir\CustomerServiceCdeConfirmationImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/cdeLignes/lbWebPort?wsdl","$currDir\CustomerServiceCdeLignesImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/cdeTete/lbWebPort?wsdl","$currDir\CustomerServiceCdeTeteImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/majDevis/lbWebPort?wsdl","$currDir\CustomerServiceDevisImp.wsdl")
    }
    
    $svcutil = get-item ((get-item 'Env:\ProgramFiles(x86)').Value + "\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\svcutil.exe")
    $csc = get-item ((get-item 'Env:\SystemRoot').Value + "\Microsoft.NET\Framework64\v4.0.30319\csc.exe")
    
    & $svcutil WSDefinition\CustomerServiceTypes.xsd /importxmltypes /i /dconly /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer" /o:MyCustomer\Types.cs 
    
    & $csc /target:library /out:temp.dll MyCustomer\Types.cs
    
    & $svcutil WSDefinition\CustomerServiceMajClientImpl.wsdl WSDefinition\CustomerServiceTypes.xsd /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.MajClient"  /o:MyCustomer\MajClient.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceLotClientImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.LotClient"  /o:MyCustomer\LotClient.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceInterlocuteursImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.Interlocuteurs"  /o:MyCustomer\Interlocuteurs.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceCdeConfirmationImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.CdeConfirmation"  /o:MyCustomer\CdeConfirmation.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceCdeLignesImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.CdeLignes"  /o:MyCustomer\CdeLignes.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceCdeTeteImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.CdeTete"  /o:MyCustomer\CdeTete.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceDevisImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.Devis"  /o:MyCustomer\Devis.cs /s /tcv:Version35 /r:temp.dll
    
    Remove-Item temp.dll
    

  • 我终于能够使用一个糟糕的powershell脚本解除所有内容

    关键思想是为所有服务指定一个自定义名称空间。 但由于某些部分(返回类型)在所有服务中共享,我不得不从XSD中提取类型并引用它。过程是这样的:

  • 如果需要,下载最新的wsdl文件
  • 设置工具的路径
  • 根据xsd文件中定义的类型创建cs文件
  • 在临时dll中编译此cs文件
  • 对于每个服务,使用svcutil创建代理。注意“共享”公共类型所需的
    /r:Temp.dll
  • 删除temp.dll文件

        $web = new-object System.Net.WebClient
    $currDir = (get-item WSDefinition).FullName
    
    if($false) // Set to true if wsdl changed
    {
        $web.DownloadFile("http://urlofmywebservice/majClient/lbWebPort?wsdl","$currDir\CustomerServiceMajClientImpl.wsdl")
        $web.DownloadFile("http://urlofmywebservice/lotClient/lbWebPort?wsdl","$currDir\CustomerServiceLotClientImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/interlocuteur/lbWebPort?wsdl","$currDir\CustomerServiceInterlocuteursImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/cdeConf/lbWebPort?wsdl","$currDir\CustomerServiceCdeConfirmationImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/cdeLignes/lbWebPort?wsdl","$currDir\CustomerServiceCdeLignesImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/cdeTete/lbWebPort?wsdl","$currDir\CustomerServiceCdeTeteImp.wsdl")
        $web.DownloadFile("http://urlofmywebservice/majDevis/lbWebPort?wsdl","$currDir\CustomerServiceDevisImp.wsdl")
    }
    
    $svcutil = get-item ((get-item 'Env:\ProgramFiles(x86)').Value + "\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\svcutil.exe")
    $csc = get-item ((get-item 'Env:\SystemRoot').Value + "\Microsoft.NET\Framework64\v4.0.30319\csc.exe")
    
    & $svcutil WSDefinition\CustomerServiceTypes.xsd /importxmltypes /i /dconly /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer" /o:MyCustomer\Types.cs 
    
    & $csc /target:library /out:temp.dll MyCustomer\Types.cs
    
    & $svcutil WSDefinition\CustomerServiceMajClientImpl.wsdl WSDefinition\CustomerServiceTypes.xsd /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.MajClient"  /o:MyCustomer\MajClient.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceLotClientImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.LotClient"  /o:MyCustomer\LotClient.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceInterlocuteursImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.Interlocuteurs"  /o:MyCustomer\Interlocuteurs.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceCdeConfirmationImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.CdeConfirmation"  /o:MyCustomer\CdeConfirmation.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceCdeLignesImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.CdeLignes"  /o:MyCustomer\CdeLignes.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceCdeTeteImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.CdeTete"  /o:MyCustomer\CdeTete.cs /s /tcv:Version35 /r:temp.dll
    & $svcutil WSDefinition\CustomerServiceDevisImp.wsdl WSDefinition\CustomerServiceTypes.xsd /mergeconfig /config:MyCustomerServices.config /mc /a /i /n:"*,MyCustomer.Project.Interfaces.Erp.WebServices.MyCustomer.Devis"  /o:MyCustomer\Devis.cs /s /tcv:Version35 /r:temp.dll
    
    Remove-Item temp.dll