问题
I'm attempting to build a WCF client in C# to consume eMedNy's SOAP web services. The WSDL is here: https://service100.emedny.org:9047/MHService?wsdl
When I try running svcutil
I get this error:
Warning: The following Policy Assertions were not Imported:
XPath://wsdl:definitions[@targetNamespace=http://org/emedny/mhs/
]/wsdl:binding[@name='MHS']
Assertions:<dpe:summary xmlns:dpe='http://www.datapower.com/extensions'> .. </dpe:summary>
<sp:SupportingTokens xmlns:sp='http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702'> .. </sp:SupportingTokens>
From what I've read, this has something to do with WCF's lack of support for usernameToken
with digested password.
How can I proceed to overcome this and set-up the proxy and app.config
?
回答1:
Save the WSDL and any referenced WSDL/schema locally on disk. (You can find referenced files by following the "import" and "include" elements.) After you save them on disk, resolve the references: for example, if import tag was to http://www.server.com/1.WSDL and you saved it on disk to 1.wsdl then change the import tag to point to local disk. Then delete all the policy tags from the WSDL (actually just one - the root policy tag and all its children). Now you should be able to add service reference from the root WSDL on local disk.
EDIT: based on your comment the issue now is not generating the proxy but configuring security. Based on your link this is a fairly complicated security configuration to set up. Try look at this link as a base binding. Then include this to make the binary token appear serialized (might need to alter InclusionMode and ReferenceStyle). It might take quite a few adjustments to get the exact format you need. At any stage use Fiddler or WCF logs to see how your request is aligned with the desired SOAP format.
来源:https://stackoverflow.com/questions/21244396/svcutil-getting-stuck-on-usernametoken-policy