C# 发送Soap请求并捕获响应

C# 发送Soap请求并捕获响应,c#,wpf,web-services,soap,C#,Wpf,Web Services,Soap,我正在尝试构建WPF程序,以便根据作为服务引用添加的WSDL将Soap请求创建为xml文件。 问题是,我无法将代理类配置为使用该xml文件并将其作为请求发送和接收响应。这给了我一个例外: mscorlib.dll中发生“System.ServiceModel.FaultException”“1”类型的未处理异常 附加信息:应用程序错误 向下编辑代码以忽略不与webservice调用交互的对象,将提供: ConsignmentEndpointClient proxy = new Consignme

我正在尝试构建WPF程序,以便根据作为服务引用添加的WSDL将Soap请求创建为xml文件。
问题是,我无法将代理类配置为使用该xml文件并将其作为请求发送和接收响应。这给了我一个例外:

mscorlib.dll中发生“System.ServiceModel.FaultException”“1”类型的未处理异常 附加信息:应用程序错误


向下编辑代码以忽略不与webservice调用交互的对象,将提供:

ConsignmentEndpointClient proxy = new ConsignmentEndpointClient();
save sv = new save();
response= proxy.save(sv);  /*Here occur the exception*/
在不知道Web服务期望的情况下,看起来您正在尝试保存一个全新的对象,该对象没有以任何方式进行更改(这可能是有效的,也可能不是有效的)。您没有处理它抛出的异常,这就是它未被处理的原因-您可以简单地将其移动到
try
块的调用范围内,这样更像:

private void button1_Click(object sender, RoutedEventArgs e)
{
    try
    {
        ConsignmentEndpointClient proxy = new ConsignmentEndpointClient();
        save sv = new save();

        throw new NotImplementedExcetpion("This probably needs to be associated with your sv object in some way, or just removed altogether");

        XmlDocument doc = new XmlDocument();
        doc.Load(PATH);
        saveResponse response = proxy.save(sv);  /*Here occur the exception*/

        Output.Text = "Response : \n" + returnSerializedxml(response);     
    }
    catch (Exception error)
    {
        Output.Text = "Error in Request : \n" + error;
    }
}
private void button1_Click(object sender, RoutedEventArgs e)
{
    try
    {
        ConsignmentEndpointClient proxy = new ConsignmentEndpointClient();
        save sv = new save();

        throw new NotImplementedExcetpion("This probably needs to be associated with your sv object in some way, or just removed altogether");

        XmlDocument doc = new XmlDocument();
        doc.Load(PATH);
        saveResponse response = proxy.save(sv);  /*Here occur the exception*/

        Output.Text = "Response : \n" + returnSerializedxml(response);     
    }
    catch (Exception error)
    {
        Output.Text = "Error in Request : \n" + error;
    }
}