Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Glenn Duncan   on Nov 27 In Java Category.

  
Question Answered By: Percy Morgan   on Nov 27

Oracle JDeveloper 9.0.3 has a built-in wizard to create java-clients (stubs) from wsdl file. I believe there are also other free ware tools.

When you get the required packages you can work it out with following high-level API example (extract)


package mypackage;

import oracle.soap.transport.http.OracleSOAPHTTPConnection;
import org.apache.soap.encoding.soapenc.BeanSerializer;
import org.apache.soap.encoding.SOAPMappingRegistry;
import org.apache.soap.util.xml.QName;
import java.net.URL;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.SOAPException;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;
import java.util.Vector;
import java.util.Properties;

public class SOAPProfileManagerStub
{
public SOAPProfileManagerStub()
{
m_httpConnection = new OracleSOAPHTTPConnection();
m_smr = new SOAPMappingRegistry();
}


public String endpoint = "http://localhost/soap/SOAPProfileManagerService";
private OracleSOAPHTTPConnection m_httpConnection = null;
private SOAPMappingRegistry m_smr = null;

public Boolean isPermitted(String authCode, String element) throws Exception
{
Boolean returnVal = null;

URL endpointURL = new URL(endpoint);
Call call = new Call();
call.setSOAPTransport(m_httpConnection);
call.setTargetObjectURI("SOAPProfileManagerService");
call.setMethodName("isPermitted");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

Vector params = new Vector();
params.addElement(new Parameter("authCode", java.lang.String.class, authCode, null));
params.addElement(new Parameter("element", java.lang.String.class, element, null));
call.setParams(params);

call.setSOAPMappingRegistry(m_smr);

Response response  = call.invoke(endpointURL, "");

if (!response.generatedFault())
{
Parameter result = response.getReturnValue();
returnVal = (Boolean)result.getValue();
}
else
{
Fault fault = response.getFault();
throw new SOAPException(fault.getFaultCode(), fault.getFaultString());
}

return returnVal;
}

}

Share: