none
Content-Type problem consuming an axia2 service in C# RRS feed

  • Question

  • 

    Hi... I am a newbee to web servce, so please bear with me.

    I am trying to consume the web service of IBM TRational Change, but get an Exception when receiving the response to my requests.

    I started by adding the reference in my project, by pointing to the wsdl file in the service, which seems to complete without errors.

    All service calls I have tried, result in an exception bassically telling that the Content-Type is not what was expected by the binding (see below).

    Exception:

    The content type multipart/related; boundary=MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035; type="application/xop+xml"; start="<0.urn:uuid:DC4B43F15F54F501651403867648036@apache.org>"; start-info="text/xml";charset=windows-1252 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 790 bytes of the response were: '--MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035
    Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
    Content-Transfer-Encoding: binary
    Content-ID: <0.urn:uuid:DC4B43F15F54F501651403867648036@apache.org>
    
    <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:getLoginInfoResponse xmlns:ns1="http://www.telelogic.com/change/types"><loginInfo><loginRoles><string>ReportBuilder</string><string>Admin</string><string>User</string></loginRoles><databases><databaseInfo><name>\\dcedit02\cbtcdb\cbtc_live</name><label>cbtc_live</label><description>cbtc_live</description><enabled>true</enabled></databaseInfo></databases></loginInfo></ns1:getLoginInfoResponse></soapenv:Body></soapenv:Envelope>'.
    

    The soap envelope in the response tell that the call was success full on the service side, and this is the same when callling login and logout. By looking at the soap content I can see that I can login an user and get a valid token.

    It is the WCF client side that doesn't accept the response.

    I created a TCP proxy dumping application to see what is sent. It seems like the web service is always sending a mime encoded reply, which probably is what confuses the client (see dump below).

    In the help page, it states that the service uses wrapped document/literal style soap messages, and MTOM for attachments. There is a note to check if the client supports HTTP chunking. From an exception message, I can see that the service is using axis2.

    Can someone help me with what to do to get a C# client working with this mime encoded axis2 service?

    Dump of messages:

    13:14:07.537 Got 193 bytes from: 127.0.0.1:1500
    POST /cbtc/webservices/ChangeService HTTP/1.1
    Content-Type: text/xml; charset=utf-8
    SOAPAction: ""
    Host: 127.0.0.1:8601
    Content-Length: 254
    Expect: 100-continue
    Connection: Keep-Alive
    
    
    13:14:07.537 Got 25 bytes from: 10.83.5.162:8601
    HTTP/1.1 100 Continue
    
    
    13:14:07.537 Got 254 bytes from: 127.0.0.1:1500
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><getLoginInfo xmlns="http://www.telelogic.com/change/types"/></s:Body></s:Envelope>
    13:14:07.537 Got 1202 bytes from: 10.83.5.162:8601
    HTTP/1.1 200 OK
    Date: Fri, 27 Jun 2014 11:14:07 GMT
    Server: Jetty/5.1.14 (Windows Server 2003/5.2 build 3790 Service Pack 2 x86 java/1.6.0
    Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035; type="application/xop+xml"; start="<0.urn:uuid:DC4B43F15F54F501651403867648036@apache.org>"; start-info="text/xml";charset=windows-1252
    Transfer-Encoding: chunked
    
    316
    --MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035
    Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
    Content-Transfer-Encoding: binary
    Content-ID: <0.urn:uuid:DC4B43F15F54F501651403867648036@apache.org>
    
    <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:getLoginInfoResponse xmlns:ns1="http://www.telelogic.com/change/types"><loginInfo><loginRoles><string>ReportBuilder</string><string>Admin</string><string>User</string></loginRoles><databases><databaseInfo><name>\\dcedit02\cbtcdb\cbtc_live</name><label>cbtc_live</label><description>cbtc_live</description><enabled>true</enabled></databaseInfo></databases></loginInfo></ns1:getLoginInfoResponse></soapenv:Body></soapenv:Envelope>
    
    13:14:07.537 Got 74 bytes from: 10.83.5.162:8601
    38
    
    --MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035
    2
    --
    0
    
    

    Best regards

    Kent

    
    Friday, June 27, 2014 1:40 PM

All replies

  • 

    Hi... I am a newbee to web servce, so please bear with me.

    I am trying to consume the web service of IBM TRational Change, but get an Exception when receiving the response to my requests.

    I started by adding the reference in my project, by pointing to the wsdl file in the service, which seems to complete without errors.

    All service calls I have tried, result in an exception bassically telling that the Content-Type is not what was expected by the binding (see below).

    Exception:

    The content type multipart/related; boundary=MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035; type="application/xop+xml"; start="<0.urn:uuid:DC4B43F15F54F501651403867648036@apache.org>"; start-info="text/xml";charset=windows-1252 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 790 bytes of the response were: '--MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035
    Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
    Content-Transfer-Encoding: binary
    Content-ID: <0.urn:uuid:DC4B43F15F54F501651403867648036@apache.org>
    
    <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:getLoginInfoResponse xmlns:ns1="http://www.telelogic.com/change/types"><loginInfo><loginRoles><string>ReportBuilder</string><string>Admin</string><string>User</string></loginRoles><databases><databaseInfo><name>\\dcedit02\cbtcdb\cbtc_live</name><label>cbtc_live</label><description>cbtc_live</description><enabled>true</enabled></databaseInfo></databases></loginInfo></ns1:getLoginInfoResponse></soapenv:Body></soapenv:Envelope>'.

    The soap envelope in the response tell that the call was success full on the service side, and this is the same when callling login and logout. By looking at the soap content I can see that I can login an user and get a valid token.

    It is the WCF client side that doesn't accept the response.

    I created a TCP proxy dumping application to see what is sent. It seems like the web service is always sending a mime encoded reply, which probably is what confuses the client (see dump below).

    In the help page, it states that the service uses wrapped document/literal style soap messages, and MTOM for attachments. There is a note to check if the client supports HTTP chunking. From an exception message, I can see that the service is using axis2.

    Can someone help me with what to do to get a C# client working with this mime encoded axis2 service?

    Dump of messages:

    13:14:07.537 Got 193 bytes from: 127.0.0.1:1500
    POST /cbtc/webservices/ChangeService HTTP/1.1
    Content-Type: text/xml; charset=utf-8
    SOAPAction: ""
    Host: 127.0.0.1:8601
    Content-Length: 254
    Expect: 100-continue
    Connection: Keep-Alive
    
    
    13:14:07.537 Got 25 bytes from: 10.83.5.162:8601
    HTTP/1.1 100 Continue
    
    
    13:14:07.537 Got 254 bytes from: 127.0.0.1:1500
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><getLoginInfo xmlns="http://www.telelogic.com/change/types"/></s:Body></s:Envelope>
    13:14:07.537 Got 1202 bytes from: 10.83.5.162:8601
    HTTP/1.1 200 OK
    Date: Fri, 27 Jun 2014 11:14:07 GMT
    Server: Jetty/5.1.14 (Windows Server 2003/5.2 build 3790 Service Pack 2 x86 java/1.6.0
    Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035; type="application/xop+xml"; start="<0.urn:uuid:DC4B43F15F54F501651403867648036@apache.org>"; start-info="text/xml";charset=windows-1252
    Transfer-Encoding: chunked
    
    316
    --MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035
    Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
    Content-Transfer-Encoding: binary
    Content-ID: <0.urn:uuid:DC4B43F15F54F501651403867648036@apache.org>
    
    <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:getLoginInfoResponse xmlns:ns1="http://www.telelogic.com/change/types"><loginInfo><loginRoles><string>ReportBuilder</string><string>Admin</string><string>User</string></loginRoles><databases><databaseInfo><name>\\dcedit02\cbtcdb\cbtc_live</name><label>cbtc_live</label><description>cbtc_live</description><enabled>true</enabled></databaseInfo></databases></loginInfo></ns1:getLoginInfoResponse></soapenv:Body></soapenv:Envelope>
    
    13:14:07.537 Got 74 bytes from: 10.83.5.162:8601
    38
    
    --MIMEBoundaryurn_uuid_DC4B43F15F54F501651403867648035
    2
    --
    0
    

    Best regards

    Kent

    

    Sorry, I forgot to mention that I am using Visual Studio 2008 Express. I have tried the 2005 express version too, with a similar result.
    Friday, June 27, 2014 1:47 PM
  • There are several means you can consider when you try to consume a XML webservice(no matter what platform it is built upon) from .NET client:

    1. If a well-defined WSDL metadata document is provided, it is recommeded that you use "Add WebReference"(for traditional ASMX webservice client) or "Add serviceReference"(for the WCF based client proxy) to generate proxy class and use proxy class to consume the service.

    2. If the service or the request/response message of the service operations are not very complicated and won't involve complicated WS-* protcocols(such as ws-security). Then you can ask for a sample SOAP request/response message from the service provider. After that you can directly use HttpWebRequest component to call the service and maually generate request message via XML document classes and also receive the response as  raw XML document and parse it.


    #Accessing Webservice by using Sys.Net.WebRequest
    http://www.dotnetfunda.com/articles/article480-accessing-webservice-by-using-sysnetwebrequest-.aspx

    #Invoking Web Service dynamically using HttpWebRequest
    http://geekswithblogs.net/marcel/archive/2007/03/26/109886.aspx

    Monday, June 30, 2014 10:22 AM