Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.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# 调用工作流服务,而不将其作为服务添加到解决方案中_C#_Workflow Foundation_Workflow Foundation 4_Workflow Activity_Workflowservice - Fatal编程技术网

C# 调用工作流服务,而不将其作为服务添加到解决方案中

C# 调用工作流服务,而不将其作为服务添加到解决方案中,c#,workflow-foundation,workflow-foundation-4,workflow-activity,workflowservice,C#,Workflow Foundation,Workflow Foundation 4,Workflow Activity,Workflowservice,我正在从事一个asp.net项目,该项目调用工作流服务。我想调用该服务,而不将其作为服务添加到解决方案中。我正在使用以下代码 XNamespace ns = "http://schemas.microsoft.com/2003/10/Serialization/"; var factory = new ChannelFactory<IGenericService>(new BasicHttpBinding(), new EndpointAddress("http://localho

我正在从事一个asp.net项目,该项目调用工作流服务。我想调用该服务,而不将其作为服务添加到解决方案中。我正在使用以下代码

XNamespace ns = "http://schemas.microsoft.com/2003/10/Serialization/";

var factory = new ChannelFactory<IGenericService>(new BasicHttpBinding(), new EndpointAddress("http://localhost:2757/BPMNSimple.xamlx"));

var proxy = factory.CreateChannel();

var request = Message.CreateMessage(MessageVersion.Soap11, "http://tempuri.org/IService/TestSimple", new XElement(ns + "string", "45"));

var response = proxy.GetData(request); 

var xml = (XElement)XElement.ReadFrom(response.GetReaderAtBodyContents());
var message = xml.Value;
lblMessage.Text = message.ToString();

在第一个实例中,在服务端打开IncludeExceptionDetailsInFaults。您将能够从中获得更多信息

您需要在services web.config中添加以下内容:

 <serviceDebug includeExceptionDetailInFaults="true" />

艾德: 因此,下一步要尝试的是使用内置的错误处理,看看您是否可以看到serveside发生了什么。读一读这个。您需要添加以下内容:

<configuration>
 <system.diagnostics>
  <sources>
        <source name="System.ServiceModel" 
                switchValue="Information, ActivityTracing"
                propagateActivity="true">
        <listeners>
           <add name="traceListener" 
               type="System.Diagnostics.XmlWriterTraceListener" 
               initializeData= "c:\log\Traces.svclog" />
        </listeners>
     </source>
  </sources>
</system.diagnostics>

这将创建一个WCF日志文件,您可以(希望)在其中看到与您的请求相关的错误

<configuration>
 <system.diagnostics>
  <sources>
        <source name="System.ServiceModel" 
                switchValue="Information, ActivityTracing"
                propagateActivity="true">
        <listeners>
           <add name="traceListener" 
               type="System.Diagnostics.XmlWriterTraceListener" 
               initializeData= "c:\log\Traces.svclog" />
        </listeners>
     </source>
  </sources>
</system.diagnostics>