Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-3385

Axis2 integration returns "Unsupported Content-Type: text/html;charset=utf-8 Supported ones are: [text/xml]" with .Net

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Reopened
    • Major
    • Resolution: Unresolved
    • Trunk, Upcoming Branch
    • None
    • framework
    • None
    • Bug Crush Event - 21/2/2015

    Description

      I have setup the findPartiesById service to export="true" and tried to call the web service using Netbeans 6.5.

      I received the following error message:

      com.sun.xml.internal.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/html;charset=utf-8 Supported ones are: [text/xml]
              at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:284)
              at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:118)
              at com.sun.xml.internal.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:278)
              at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:180)
              at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
              at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
              at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
              at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
              at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
              at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
              at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
              at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124)
              at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
              at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
              at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
              at $Proxy28.findPartiesById(Unknown Source)
              at javaapplication7.Main.main(Main.java:74)
      

      Watching the tcp steam with wireshark, I can see that the prefix ns2 is added to the map-Entry items:

      <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
         <S:Body>
            <ns2:findPartiesById xmlns:ns2="http://ofbiz.apache.org/service/">
               <map-Map>
                  <ns2:map-Entry>
                     <ns2:map-Key>
                        <ns2:std-String value="idToFind"/>
                     </ns2:map-Key>
                     <ns2:map-Value>
                        <ns2:std-String value="admin"/>
                     </ns2:map-Value>
                  </ns2:map-Entry>
                  <ns2:map-Entry>
                     <ns2:map-Key>
                        <ns2:std-String value="login.username"/>
                     </ns2:map-Key>
                     <ns2:map-Value>
                        <ns2:std-String value="admin"/>
                     </ns2:map-Value>
                  </ns2:map-Entry>
                  <ns2:map-Entry>
                     <ns2:map-Key>
                        <ns2:std-String value="login.password"/>
                     </ns2:map-Key>
                     <ns2:map-Value>
                        <ns2:std-String value="ofbiz"/>
                     </ns2:map-Value>
                  </ns2:map-Entry>
               </map-Map>
            </ns2:findPartiesById>
         </S:Body>
      </S:Envelope>
      

      If I copy this soap message and paste into SoapUI, the soap call fails. However, if I strip off the ns2 prefix from the map-Entry items (as below), the call succeeds:

      <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
         <S:Body>
            <ns2:findPartiesById xmlns:ns2="http://ofbiz.apache.org/service/">
               <map-Map>
                  <map-Entry>
                     <map-Key>
                        <std-String value="idToFind"/>
                     </map-Key>
                     <map-Value>
                        <std-String value="admin"/>
                     </map-Value>
                  </map-Entry>
                  <map-Entry>
                     <map-Key>
                        <std-String value="login.username"/>
                     </map-Key>
                     <map-Value>
                        <std-String value="admin"/>
                     </map-Value>
                  </map-Entry>
                  <map-Entry>
                     <map-Key>
                        <std-String value="login.password"/>
                     </map-Key>
                     <map-Value>
                        <std-String value="ofbiz"/>
                     </map-Value>
                  </map-Entry>
               </map-Map>
            </ns2:findPartiesById>
         </S:Body>
      </S:Envelope>
      

      My java class is:

      package javaapplication7;
      
      import org.apache.ofbiz.service.MapEntry;
      import org.apache.ofbiz.service.MapKey;
      import org.apache.ofbiz.service.MapMap;
      import org.apache.ofbiz.service.MapValue;
      import org.apache.ofbiz.service.StdString;
      
      public class Main {
      
          public static void main(String[] args) {
      
              try { 
                  org.apache.ofbiz.service.FindPartiesById service = new org.apache.ofbiz.service.FindPartiesById();
                  org.apache.ofbiz.service.FindPartiesByIdPortType port = service.getFindPartiesByIdPort();
      
                  StdString keyString = new StdString();
                  keyString.setValue("idToFind");
      
                  MapKey mapKey = new MapKey();
                  mapKey.setStdString(keyString);
                  
                  StdString valueString = new StdString();
                  valueString.setValue("admin");            
                  
                  MapValue mapValue = new MapValue();
                  mapValue.setStdString(valueString);
      
                  MapEntry mapEntry = new MapEntry();
                  mapEntry.setMapKey(mapKey);
                  mapEntry.setMapValue(mapValue);
      
                  StdString keyStringLogin = new StdString();
                  keyStringLogin.setValue("login.username");
      
                  MapKey mapKeyLogin = new MapKey();
                  mapKeyLogin.setStdString(keyStringLogin);
      
                  StdString valueStringLogin = new StdString();
                  valueStringLogin.setValue("admin");
      
                  MapValue mapValueLogin = new MapValue();
                  mapValueLogin.setStdString(valueStringLogin);
      
                  MapEntry mapEntryLogin = new MapEntry();
                  mapEntryLogin.setMapKey(mapKeyLogin);
                  mapEntryLogin.setMapValue(mapValueLogin);
      
                  StdString keyStringPassword = new StdString();
                  keyStringPassword.setValue("login.password");
      
                  MapKey mapKeyPassword = new MapKey();
                  mapKeyPassword.setStdString(keyStringPassword);
      
                  StdString valueStringPassword = new StdString();
                  valueStringPassword.setValue("ofbiz");
      
                  MapValue mapValuePassword = new MapValue();
                  mapValuePassword.setStdString(valueStringPassword);
      
                  MapEntry mapEntryPassword = new MapEntry();
                  mapEntryPassword.setMapKey(mapKeyPassword);
                  mapEntryPassword.setMapValue(mapValuePassword);
      
                  MapMap myMap = new MapMap();
                  myMap.getMapEntry().add(mapEntry);
                  myMap.getMapEntry().add(mapEntryLogin);
                  myMap.getMapEntry().add(mapEntryPassword);
      
                  javax.xml.ws.Holder<org.apache.ofbiz.service.MapMap> mapMap = 
                          new javax.xml.ws.Holder<org.apache.ofbiz.service.MapMap>(myMap);
      
                  port.findPartiesById(mapMap);
      
              } catch (Exception ex) {
                  ex.printStackTrace();
              }
          }
      }
      

      Attachments

        1. patch.txt
          2 kB
          chris snow
        2. patch2.txt
          2 kB
          chris snow

        Issue Links

          Activity

            People

              Unassigned Unassigned
              snowch chris snow
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: