File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

convert soap RPC call to document/literal

 
siebel admin
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gurus,
I wrote a simple web service client with saaj API.The request gests posted as SOAP_RPC_CALL but the consuming application doesn't identify RPC calls, it only accepts SOAP_DOC_LITERAL.I tried to set mimeheaders to change the action to post as document, i get an error as

"Aug 5, 2012 11:03:50 AM com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
SEVERE: SAAJ0008: Bad Response; Bad request"


===============================
package saagapiprogram;

import java.io.IOException;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;

public class SAAGAPIProgram {
public static void main(String[] args) throws SOAPException, IOException {
try {
SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = factory.createConnection();
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
MimeHeaders hd = message.getMimeHeaders();
hd.addHeader("SOAPAction", "document/http://xmlns.oracle.com/apps/mdm/customer:lookupsiebel");
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
SOAPElement bodyElement = body.addChildElement(envelope.createName("lookupWallet_Input", "cus", "http://xmlns.oracle.com/apps/mdm/customer"));
bodyElement.addChildElement("aaaaa").addTextNode("Tssss");
message.saveChanges();
System.out.println("\nRequest:\n");
message.writeTo(System.out);
String destination = "http://XXXXX:0808/eai_enu/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&UserName=XXX&Password=XXXX";
SOAPMessage reply = connection.call(message, destination);
System.out.println("\nRESPONSE:\n");

TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
Source sourceContent = reply.getSOAPPart().getContent();
StreamResult result = new StreamResult(System.out);
transformer.transform(sourceContent, result);
System.out.println();
connection.close();
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}

Thanks
Rama
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic