使用WF通过HTTPS调用Soap服务

时间:2017-05-23 19:17:40

标签: wcf ssis soap-client

我已经针对Postman测试了端点,尽管视觉工作室声称它确实存在。添加服务引用时,app.config文件中出现错误,因此我决定在代码中手动配置绑定和端点。

脚本任务:

public void Main()
    {

        //configure WCF manually , endpoint, HTTPS binding, etc
        BasicHttpsBinding binding = new System.ServiceModel.BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
        EndpointAddress address = new EndpointAddress("https://service/services/Operation.svc");
        ST_364d1c14d92b406e87f51c75a462f403.ClientServiceRef.ClientService1Client client = new ClientService1Client(binding, address);
        client.ClientCredentials.UserName.UserName = "";
        client.ClientCredentials.UserName.Password = "";

        //make call to SOAP service using client instance
        var column_names = client.GetAllClients();
        Dts.TaskResult = (int)ScriptResults.Success;
    }

运行时错误 - 似乎无法识别端点

 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

这里是app.config文件的参考

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IClientService1">
                    <security mode="Transport" />
                </binding>
                <binding name="BasicHttpBinding_IClientService11" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https:/server.com/services/ClientService1.svc/soap"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IClientService1"
                contract="ClientServiceRef.IClientService1" name="BasicHttpBinding_IClientService1" />
        </client>
    </system.serviceModel>
</configuration>

0 个答案:

没有答案