Saturday 1 December 2012

Consuming "No WSDL" services

Oracle Service Bus offers to have "Any XML" or "Any SOAP" proxy services. These services do not have associated WSDLs so it means that you can not use standard features, such Web Services Data Control or Web Services Proxy. Instead one option is to use java class to consume such services. E.g.


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

import javax.faces.component.html.HtmlCommandButton;
import javax.faces.event.ActionEvent;


    public void runPrepareTransaction(ActionEvent actionEvent) {
        try {
            String data = inputText.getValue().toString();
            URL url =
                new URL("http://blabla.com/Proxy/PrepareTransaction");
            URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            OutputStreamWriter oSW =
                new OutputStreamWriter(conn.getOutputStream());
            oSW.write(data);
            oSW.flush();
            BufferedReader bR =
                new BufferedReader(new InputStreamReader(conn.getInputStream()));
            int i = 0;
            String line;
            while ((line = bR.readLine()) != null) {
                System.out.println("Line is : " + i + " : " +
                                   line);
                i++;
            }
            oSW.close();
            bR.close();
        } catch (Exception e) {
        }
    }



Monday 26 November 2012

Creating Web Services Proxy in JDeveloper

Probem: Faced the following issues while creating web services proxy in JDeveloper.

Caused by: oracle.jdeveloper.webservices.tools.WsdlValidationException: Error creating model from wsdl "https://blabla/TaxService.asmx?WSDL": A class/interface with the same name "acb.web.ArrayOfTaxControl" is already in use. Use a class customization to resolve this conflict.(Relevant to above error) another "ArrayOfTaxControl" is generated from here.Two declarations cause a collision in the ObjectFactory class.(Related to above error) This is the other declaration.

Solution: Do not to enter anything in "Package name" and "Root Package for Generated Types" fields at "Specify Default Mapping Options" screen.

Reason: Apparatently, when you put the package names, JDeveloper is trying to create objects with the same name in the same location (given by "Root Package for Generated Types" field value).

Problem: oracle.j2ee.ws.wsdl.LocalizedWSDLException: WSDLException: faultCode=PARSER_ERROR: Failed to read wsdl file at: "file:/C:/projects/workspace/BlaBlaWebServices/Model/src/https/blabla/TaxService.wsdl", caused by: java.io.UTFDataFormatException.    : java.io.UTFDataFormatException: Invalid UTF8 encoding.

Solution: Remove "Copy WSDL Into Project" option.