Invalid response content type using Mule as .Net Client/Webservice mediator

View: New views
5 Messages — Rating Filter:   Alert me  

Invalid response content type using Mule as .Net Client/Webservice mediator

by Gerwin Postma :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

G'Day everyone, greetings from Downunder!

Here is what I am trying to do:

I have a webservice and a client both in .net
Need to use Mule as a mediator between the two, i.e. client > Mule > service > Mule > client
The point of the excercise is so that using Mule, client end-points need not to change in case of web service endpoint changes due to versioning, replacement, etc providing a lot of flexibility.

The Client and WebService I am using are very simple, enough to test the concept.

Client:

public partial class _Default : System.Web.UI.Page
{
    protected void Button1_Click(object sender, EventArgs e)
    {
        localhost.PatientAddmissionService pms = new localhost.PatientAddmissionService();
        Label1.Text = pms.AddmitPatient(TextBox1.Text.ToString());
    }
}

WebService listening on http://localhost:54455

namespace PMSDemo called PatientAddmissionService.asmx
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class PatientAddmissionService : System.Web.Services.WebService
    {

        [WebMethod]
        public string AddmitPatient(string patientID)
        {
            return patientID + " admitted successfully on " + DateTime.Now;
        }
    }
}

Here is what I have done:

used the following config:

<model name="Mediator">
    <service name="HttpProxyService">
      <inbound>
        <inbound-endpoint address="http://localhost:8888" synchronous="true"/>
      </inbound>
      <outbound>
        <pass-through-router>
          <outbound-endpoint address="http://localhost:54455#[header:http.request]" synchronous="true"/>
        </pass-through-router>
      </outbound>
    </service>
  </model>
</mule>


This is as far as I got:

The below error message contains a valid soap structure (compared it to a valid repsonse soap message), however it seems that the content type of the message returned by Mule is not XML and the client doesn't like it.
I say Mule because if I remove Mule as the mediator and setup the client end-point to directly connect to the service, it all works.


Client found response content type of 'text/plain', but expected 'text/xml'.
The request failed with the error message:
--
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><AddmitPatientResponse xmlns="http://tempuri.org/"><AddmitPatientResult>sep admitted successfully on 30/10/2009 12:43:52 PM</AddmitPatientResult></AddmitPatientResponse></soap:Body></soap:Envelope>
--.

As you can see I am pretty new to Mule and WebServices in general so any assitance would be appreciated.

Thanks in advance.
Sep

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Invalid response content type using Mule as .Net Client/Webservice mediator

by David Dossot-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have you tried adding a response transformer on the inbound HTTP endpoint to add a content-type header to Mule's response?

D.


On Thu, Oct 29, 2009 at 7:55 PM, sep mahdavi <mule.user.relay@...> wrote:
G'Day everyone, greetings from Downunder!

Here is what I am trying to do:

I have a webservice and a client both in .net
Need to use Mule as a mediator between the two, i.e. client > Mule > service > Mule > client
The point of the excercise is so that using Mule, client end-points need not to change in case of web service endpoint changes due to versioning, replacement, etc providing a lot of flexibility.

The Client and WebService I am using are very simple, enough to test the concept.

Client:

public partial class _Default : System.Web.UI.Page
{
   protected void Button1_Click(object sender, EventArgs e)
   {
       localhost.PatientAddmissionService pms = new localhost.PatientAddmissionService();
       Label1.Text = pms.AddmitPatient(TextBox1.Text.ToString());
   }
}

WebService listening on http://localhost:54455

namespace PMSDemo called PatientAddmissionService.asmx
{
   [WebService(Namespace = "http://tempuri.org/")]
   [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
   [ToolboxItem(false)]
   public class PatientAddmissionService : System.Web.Services.WebService
   {

       [WebMethod]
       public string AddmitPatient(string patientID)
       {
           return patientID + " admitted successfully on " + DateTime.Now;
       }
   }
}

Here is what I have done:

used the following config:

<model name="Mediator">
   <service name="HttpProxyService">
     <inbound>
       <inbound-endpoint address="http://localhost:8888" synchronous="true"/>
     </inbound>
     <outbound>
       <pass-through-router>
         <outbound-endpoint address="http://localhost:54455#[header:http.request]" synchronous="true"/>
       </pass-through-router>
     </outbound>
   </service>
 </model>
</mule>


This is as far as I got:

The below error message contains a valid soap structure (compared it to a valid repsonse soap message), however it seems that the content type of the message returned by Mule is not XML and the client doesn't like it.
I say Mule because if I remove Mule as the mediator and setup the client end-point to directly connect to the service, it all works.


Client found response content type of 'text/plain', but expected 'text/xml'.
The request failed with the error message:
--
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><AddmitPatientResponse xmlns="http://tempuri.org/"><AddmitPatientResult>sep admitted successfully on 30/10/2009 12:43:52 PM</AddmitPatientResult></AddmitPatientResponse></soap:Body></soap:Envelope>
--.

As you can see I am pretty new to Mule and WebServices in general so any assitance would be appreciated.

Thanks in advance.
Sep

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Re: Invalid response content type using Mule as .Net Client/We

by Gerwin Postma :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David your a legend mate!

Definitely pointed me towards the right direction. I have to admit that at first I wasn't sure what you were talking about, but after reading up on mule transformers and searching the net, here is the full config that solved the problem.


<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:http="http://www.mulesource.org/schema/mule/http/2.2"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
    http://www.mulesource.org/schema/mule/http/2.2 http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd">

        <message-properties-transformer name="delete-content-type-header" >
                <delete-message-property key="Content-type" />
        </message-properties-transformer>

        <message-properties-transformer name="add-xml-content-type-header" >
                <add-message-property key="Content-type" value="text/xml" />
        </message-properties-transformer>

        <model name="Mediator">
                <service name="HttpProxyService">
                        <inbound>
                                <inbound-endpoint address="http://localhost:8888"
                                        responseTransformer-refs="delete-content-type-header add-xml-content-type-header"
                                        synchronous="true"/>
                        </inbound>
                        <outbound>
                                <pass-through-router>
                                        <outbound-endpoint address="http://localhost:54455#[header:http.request]" synchronous="true"/>
                                </pass-through-router>
                        </outbound>
                </service>
        </model>
</mule>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Invalid response content type using Mule as .Net Client/We

by David Dossot-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

LOL Great job on figuring out the solution on your own, based on the few keywords I dropped... you too are now part of the legend ;-)

D.

btw. did you try without the delete-content-type-header transformer? The add-xml-content-type-header should be able to override the existing content type.



On Sat, Oct 31, 2009 at 8:16 AM, sep mahdavi <mule.user.relay@...> wrote:
David your a legend mate!

Definitely pointed me towards the right direction. I have to admit that at first I wasn't sure what you were talking about, but after reading up on mule transformers and searching the net, here is the full config that solved the problem.


<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:spring="http://www.springframework.org/schema/beans"
   xmlns:http="http://www.mulesource.org/schema/mule/http/2.2"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
   http://www.mulesource.org/schema/mule/http/2.2 http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd">

       <message-properties-transformer name="delete-content-type-header" >
               <delete-message-property key="Content-type" />
       </message-properties-transformer>

       <message-properties-transformer name="add-xml-content-type-header" >
               <add-message-property key="Content-type" value="text/xml" />
       </message-properties-transformer>

       <model name="Mediator">
               <service name="HttpProxyService">
                       <inbound>
                               <inbound-endpoint address="http://localhost:8888"
                                       responseTransformer-refs="delete-content-type-header add-xml-content-type-header"
                                       synchronous="true"/>
                       </inbound>
                       <outbound>
                               <pass-through-router>
                                       <outbound-endpoint address="http://localhost:54455#[header:http.request]" synchronous="true"/>
                               </pass-through-router>
                       </outbound>
               </service>
       </model>
</mule>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Re: Invalid response content type using Mule as .Net Client/We

by Andrew Perepelytsya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



btw. did you try without the delete-content-type-header transformer? The add-xml-content-type-header should be able to override the existing content type.


It will overwrite if the overwrite attribute = true.

HTH,
Andrew