wso2 / product-apim

Welcome to the WSO2 API Manager source code! For info on working with the WSO2 API Manager repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
837 stars 781 forks source link

WSo2 APIM is giving issues with text/xml content type. #5488

Open prats2017 opened 5 years ago

prats2017 commented 5 years ago

I am new to WSo2 and am trying to do and-to-end run for my backend SOAP service i have. I have setup a SOAP service in WSo2 . I am trying to write a java client to invoke my WSo2-API which calls my SOAP service. Swagger is giving results and so is curl on command prompt. My Java client is however giving me error ---- org.wso2.client.api.ApiException: Content type "text/xml" is not supported I couldn't find any help on web. Can u please have a look and help?

C:>curl -k -X POST "https://XXXXXXXXX:8243/mycountries/v1.0.0/" -H "accept: text/xml" -H "Content-Type: text/xml" -H "Authorization: Bearer 9f33ca31-af0e-3d7f-b741-7e589e45b8fc" -d "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tri=\"http://www.etisoftware.com/triad/\"> </soapenv:Body></soapenv:Envelope>"

-------------------------------------------------------------------------------------------------------- >>>>> Exception when calling DefaultApi#post org.wso2.client.api.ApiException: Content type "text/xml" is not supported at org.wso2.client.api.ApiClient.serialize(ApiClient.java:897) at org.wso2.client.api.ApiClient.buildRequest(ApiClient.java:1140) ======================================================== public void callGateway() throws ApiException { DefaultApi defaultApi = new DefaultApi(); String accessToken = "9f33ca31-af0e-3d7f-b741-7e589e45b8fc"; //Map headers = new HashMap(); //headers.put("Accept", "text/xml"); //headers.put("Authorization", "Bearer " + accessToken); ApiClient apiClient = defaultApi.getApiClient(); apiClient.addDefaultHeader("accept", "text/xml"); apiClient.addDefaultHeader("Content-Type", "text/xml"); apiClient.addDefaultHeader("Authorization", "Bearer " + accessToken); String soAPRequest = ""+ ""+ ""+ ""+ ""+ ""; String soAPAction = "https://xxx:8243/mycountries/v1.0.0/"; System.out.println("DONE--------"+defaultApi.toString()); try { defaultApi.post(soAPRequest, soAPAction); } catch (ApiException e) { System.err.println(">>>>> Exception when calling DefaultApi#post"); e.printStackTrace(); } }
isharac commented 4 years ago

This is a limitation in the swagger library we use to generate the sdk. As a workaround you can explicitly handle the text/xml content type in the generated JAVA client.