none
pass soap xml to wcf service RRS feed

  • Question

  • Hi,

    I want to create a client application which will pass the soap xml to wcf service.  I have implemented below code but it is giving me an erro as "Remote server returned an error 404 not found". please let me know if I am missing something

    private void Form1_Load(object sender, EventArgs e) { try { StreamReader sr = new StreamReader("C:\\Test.xml"); string str = sr.ReadToEnd(); sr.Close();

    WebClient client = new WebClient(); client.Headers.Add("Content-Type", "text/xml;charset=utf-8"); client.Headers.Add("SOAPAction","http://tempuri.org/IServices/CopyDocument"); var Respnse = client.UploadString("http://Servername/testService/Services.svc",

    str); } catch (Exception ex) { }

    }



    Thursday, October 29, 2015 8:24 AM

Answers

  • Hi RahulPundlik,

    According to your description, I am not sure where you wrong. So, in my opinion is that

    maybe you can set the includeExceptionDetailInFaults="true"  like below:

     <serviceBehaviors>
            <behavior name="OAService.ServiceBehavior">          
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />         
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>

    Then, you always can set the trace and logging file with web config file to get detailed error messages.

    Like below:

    <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>
    

    For more information, please refer to the following articles:

    1.Configuring Tracing

    Best Regards,

    Grady

    Friday, October 30, 2015 1:39 AM
    Moderator
  • Hi Grady,

    Thank you for your reply. Actually I found that the URL is http://Servername/testService/Services.svc/streamservices". I have change the URL and I have solve that error, usually we use URL up to .svc but in this case I have to concatenate streamservices. After that I was getting 401 unauthorized error so I have pass the NTLM account type along with credentials and now it is working fine.

    • Marked as answer by RahulPundlik Monday, November 9, 2015 6:43 AM
    Monday, November 9, 2015 6:43 AM

All replies

  • Hi RahulPundlik,

    According to your description, I am not sure where you wrong. So, in my opinion is that

    maybe you can set the includeExceptionDetailInFaults="true"  like below:

     <serviceBehaviors>
            <behavior name="OAService.ServiceBehavior">          
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />         
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>

    Then, you always can set the trace and logging file with web config file to get detailed error messages.

    Like below:

    <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>
    

    For more information, please refer to the following articles:

    1.Configuring Tracing

    Best Regards,

    Grady

    Friday, October 30, 2015 1:39 AM
    Moderator
  • Hi Grady,

    Thank you for your reply. Actually I found that the URL is http://Servername/testService/Services.svc/streamservices". I have change the URL and I have solve that error, usually we use URL up to .svc but in this case I have to concatenate streamservices. After that I was getting 401 unauthorized error so I have pass the NTLM account type along with credentials and now it is working fine.

    • Marked as answer by RahulPundlik Monday, November 9, 2015 6:43 AM
    Monday, November 9, 2015 6:43 AM
  • Hi RahulPundlik,

    Thanks for sharing your solution.

    Best Regards,

    Grady

    Monday, November 9, 2015 6:48 AM
    Moderator