Meaningless Drivel is fun!*
The moose likes Web Services and the fly likes SOAP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "SOAP" Watch "SOAP" New topic
Author

SOAP

sambasiva sambasiva
Greenhorn

Joined: Jan 10, 2005
Posts: 4
This is My java Program.By Using this iam trying to invoking a webservice in
weblogic



import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPPart;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPBodyElement;
import java.io.FileOutputStream;
import java.io.File;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPException;
import java.io.IOException;
public class SOAPSender {

public static void main(String args[]){

try{
System.setProperty("javax.xml.soap.MessageFactory",
"weblogic.webservice.core.soap.MessageFactoryImpl");

System.setProperty("javax.xml.soap.ConnectionFactory",
"weblogic.webservice.core.soap.SOAPConnectionFactoryImpl");

MessageFactory msg_factory=MessageFactory.newInstance();
SOAPFactory soap_factory=SOAPFactory.newInstance();
SOAPMessage msg_soap=msg_factory.createMessage();
SOAPMessage msg_ressoap;
SOAPConnectionFactory con_factory=SOAPConnectionFactory.newInstance();
SOAPConnection con_soap=con_factory.createConnection();
SOAPPart part_soap=msg_soap.getSOAPPart();
SOAPEnvelope envelope_soap=part_soap.getEnvelope();
//SOAPHeader header_soap=envelope_soap.addHeader();
SOAPBody body_soap=envelope_soap.getBody();
Name name_soap=soap_factory.createName("add","a","http://First.com/plainWebservice");
SOAPBodyElement body_element=body_soap.addBodyElement(name_soap);
body_element.addAttribute(name_soap,"xmlns:m=http://First.com/plainWebservice");
Name name_childsoap1=soap_factory.createName("intVal");
SOAPElement element_soap=body_element.addChildElement(name_childsoap1);
element_soap.addTextNode("100");
Name name_childsoap2=soap_factory.createName("intVal0");
SOAPElement element_soap1=body_element.addChildElement(name_childsoap2);
element_soap1.addTextNode("100");
System.out.println("Request");
System.out.println("------------------------------------");
msg_soap.writeTo(System.out);
msg_ressoap=con_soap.call(msg_soap,"http://localhost:7001/webservice1/plainWebservice");
System.out.println("------------------------------------");
System.out.println("Response");
System.out.println("------------------------------------");
msg_ressoap.writeTo(System.out);
System.out.println("------------------------------------");
}catch(SOAPException e){e.printStackTrace();}
catch(IOException io){io.printStackTrace();}
}
}


The response Fault Message is Like This




<env:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xs
i="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.
org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><env:Header/><e
nv:Body><env:Fault><faultcode>Client</faultcode><faultstring>Internal Error: una
ble to process your request: javax.xml.soap.SOAPException: Faild to build xml no
de: Error at Line:1, token:[OPENTAGBEGIN]Undefined Symbol:a</faultstring></env:F
ault><env:Fault/></env:Body></env:Envelope>------------------------------------
 
 
subject: SOAP