none
Want REST, but unable to find endpoint element RRS feed

  • Question

  • I'm attempting to use WCF 4.0 and POX, however the data is being sent via soap and escaping the XML tags I'm sending.

    So I created an endpoint in the web.config file.

    <?xml version="1.0"?>
    <configuration>
      <system.web>
    	<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
    	<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
      </system.web>
      <system.serviceModel>
    	<services>
    	  <service name ="wcfNAVISInterfaceService.INAVISInterfaceService">
    		<endpoint name="pox" address="pox" binding="webHttpBinding" behaviorConfiguration="web"
    contract="INAVISInterfaceService" />
    	  </service>
    	</services>
    	<behaviors>
    	  <endpointBehaviors>
    		<behavior name="web">
    		  <webHttp />
    		</behavior>
    	  </endpointBehaviors>
    	  <serviceBehaviors>
    		<behavior>
    		  <serviceMetadata httpGetEnabled="true"/>
    		  <serviceDebug includeExceptionDetailInFaults="true"/>
    		</behavior>
    	  </serviceBehaviors>
    	</behaviors>
    	<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
    	<modules runAllManagedModulesForAllRequests="true"/>
    	<security>
    	  <requestFiltering>
    		<requestLimits maxAllowedContentLength="2200000000" />
    	  </requestFiltering>
    	</security>
      </system.webServer>
    </configuration>
    

    When attempting to reference the endpoint (so it can use the POX method), an error comes up.

    Dim theInterface As New wcfNAVISInterfaceService.NAVISInterfaceServiceClient("pox")
    Console.WriteLine(theInterface.ProcessXMLPayload("<Payload></Payload>"))

    Could not find endpoint element with name 'pox' and contract 'wcfNAVISInterfaceService.INAVISInterfaceService' in the ServiceModel client configuration section.

    Contents of 'INAVISInterface.vb' file -

    <ServiceContract()>
    Public Interface INAVISInterfaceService
    
    	<OperationContract()> _
    	 <WebInvoke(Method:="POST", BodyStyle:=WebMessageBodyStyle.Bare)> _
    	Function ProcessXMLPayload(XML As String) As String
    
    End Interface

    Contents of 'NAVISInterfaceService.svc.vb' -

    Public Class NAVISInterfaceService
    	Implements INAVISInterfaceService
    
    	Public Sub New()
    	End Sub
    
    	Private Function CaptureAndTransmitData(IncomingXML As String) As String Implements INAVISInterfaceService.ProcessXMLPayload
    		Dim ReturnXML As String = ProcessData(IncomingXML)
    		Return ReturnXML
    	End Function
    	Private Function ProcessData(IncomingXML As String) As String
    		If IncomingXML.ToLower.Contains("<payload>") Then
    			Return _
    			 "Here is the Payload data you sent" & vbNewLine & _
    			 "---------------------------------------------------" & vbNewLine & _
    			 IncomingXML
    		Else
    			'send back error details
    			Return _
    			 "The Payload wasn't in the correct tag <Payload> format!" & vbNewLine & vbNewLine & _
    			 "Try again."
    		End If
    	End Function
    End Class

    Contents of compiled 'NAVISInterfaceService.svc' file -

    <%@ ServiceHost Language="VB" Debug="true" Service="wcfNAVISInterfaceService.NAVISInterfaceService" CodeBehind="NAVISInterfaceService.svc.vb" %>

    Can someone please tell me what I need to do to utilize the endpoint I created in the web.config for POX use?

    I've been searching for 1 1/2 days on the web with no avail, so if at all possible, if you could provide an original solution instead of listing a link, I would greatly appreciate it.

    Thank you for your time and assistance.


    jlroper


    • Edited by Jeff Roper Friday, November 8, 2013 10:42 PM
    Thursday, November 7, 2013 11:33 PM

Answers

  • Hi,

    I see that you want to use the soap. but I see that you have used the webHttpbinding which is used for the wcf rest service. 
    So if you want to create the wcf rest service, the content of your 'NAVISInterfaceService.svc' file should be the following, or it will not host in the IIS:

    <%@ ServiceHost Language="VB" Debug="true" Service="wcfNAVISInterfaceService.NAVISInterfaceService" CodeBehind="NAVISInterfaceService.svc.vb" Factory=System.ServiceModel.Activation.WebServiceHostFactory%>


    For your question, I think using the wcf soap service will be more better for it. So if you want to use the wcf soap service, then your web configure file should be as following:

    <system.serviceModel>
        <services>
           <service name ="wcfNAVISInterfaceService.INAVISInterfaceService">
    		<endpoint name="pox" address="" binding="basicHttpBinding" contract="INAVISInterfaceService"
         />
    
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>

    After that, you can easy add the service reference, and it should work.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Friday, November 8, 2013 2:25 AM
    Moderator

All replies

  • Hi,

    I see that you want to use the soap. but I see that you have used the webHttpbinding which is used for the wcf rest service. 
    So if you want to create the wcf rest service, the content of your 'NAVISInterfaceService.svc' file should be the following, or it will not host in the IIS:

    <%@ ServiceHost Language="VB" Debug="true" Service="wcfNAVISInterfaceService.NAVISInterfaceService" CodeBehind="NAVISInterfaceService.svc.vb" Factory=System.ServiceModel.Activation.WebServiceHostFactory%>


    For your question, I think using the wcf soap service will be more better for it. So if you want to use the wcf soap service, then your web configure file should be as following:

    <system.serviceModel>
        <services>
           <service name ="wcfNAVISInterfaceService.INAVISInterfaceService">
    		<endpoint name="pox" address="" binding="basicHttpBinding" contract="INAVISInterfaceService"
         />
    
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>

    After that, you can easy add the service reference, and it should work.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Friday, November 8, 2013 2:25 AM
    Moderator
  • Due to the overhead it uses to escape XML tags, I don't want to use SOAP.  I am trying to just send text.

    Basically, instead of sending this (taken from Fiddler):

    <s:Envelope xmlns:s="<ProcessXMLPayload">http://schemas.xmlsoap.org/soap/envelope/"><s:Body><ProcessXMLPayload xmlns="<XML><Payload></Payload></XML></ProcessXMLPayload>http://tempuri.org/"><XML>&lt;Payload&gt;&lt;/Payload&gt;</XML></ProcessXMLPayload></s:Body></s:Envelope>

    I would like to see this:

    <Payload></Payload>

    After a little more reading, it sounds like REST would be the way to go.  Is my assumption correct?

    Can you tell me what I need to do to just send plain text (which happens to be XML)?


    jlroper




    • Edited by Jeff Roper Friday, November 8, 2013 4:37 PM
    Friday, November 8, 2013 2:30 AM