use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.
the class SAAJFactoryTest method testDuplicatedContentID.
public void testDuplicatedContentID() throws Exception {
String ctype = "multipart/related; boundary=MIME_Boundary; " + "start=\"<6232425701115978772--54bee05.140acdf4f8a.-7f3f>\"; " + "type=\"text/xml\"; start-info=\"text/xml\"";
InputStream is = getClass().getClassLoader().getResourceAsStream("etc/bug17367334InputMsg.txt");
MessageContextFactory mcf = MessageContextFactory.createFactory();
Packet packet = (Packet) mcf.createContext(is, ctype);
Message message = packet.getInternalMessage();
SAAJFactory factory = new SAAJFactory();
SOAPMessage saajMessage = factory.readAsSOAPMessage(SOAPVersion.SOAP_11, message);
AttachmentPart ap = (AttachmentPart) saajMessage.getAttachments().next();
Iterator it = ap.getAllMimeHeaders();
int countContentID = 0;
while (it.hasNext()) {
MimeHeader mh = (MimeHeader) it.next();
if ("Content-Id".equalsIgnoreCase(mh.getName())) {
countContentID++;
}
}
assertEquals("More than one Content-Id", 1, countContentID);
}
use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.
the class WrapperNSTest method testWrapperNS.
public void testWrapperNS() throws Exception {
Class<?> sei = MyHelloRPC.class;
DatabindingFactory fac = DatabindingFactory.newInstance();
Databinding.Builder b = fac.createBuilder(sei, null);
DatabindingModeFeature dbf = new DatabindingModeFeature("eclipselink.jaxb");
WebServiceFeature[] f = { dbf };
b.feature(f);
b.serviceName(new QName("http://echo.org/", "helloService"));
b.portName(new QName("http://echo.org/", "helloPort"));
Databinding db = b.build();
{
Method method = findMethod(sei, "echoString");
Object[] args = { "test" };
JavaCallInfo call = db.createJavaCallInfo(method, args);
MessageContext mc = db.serializeRequest(call);
SOAPMessage msg = mc.getSOAPMessage();
// System.out.println("------------------ eclipselink");
// msg.writeTo(System.out);
// System.out.println();
Node n = msg.getSOAPBody().getChildNodes().item(0);
// System.out.println("num of attributes is: "+
// n.getAttributes().getLength());
assertTrue(n.getAttributes().getLength() == 1);
}
}
use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.
the class WrapperNSTest method testWrapperNS_JAXBRI.
public void testWrapperNS_JAXBRI() throws Exception {
Class<?> sei = MyHelloRPC.class;
DatabindingFactory fac = DatabindingFactory.newInstance();
Databinding.Builder b = fac.createBuilder(sei, null);
DatabindingModeFeature dbf = new DatabindingModeFeature("glassfish.jaxb");
WebServiceFeature[] f = { dbf };
b.feature(f);
b.serviceName(new QName("http://echo.org/", "helloService"));
b.portName(new QName("http://echo.org/", "helloPort"));
Databinding db = b.build();
{
Method method = findMethod(sei, "echoString");
Object[] args = { "test" };
JavaCallInfo call = db.createJavaCallInfo(method, args);
MessageContext mc = db.serializeRequest(call);
SOAPMessage msg = mc.getSOAPMessage();
// System.out.println("------------------ glassfish");
// msg.writeTo(System.out);
// System.out.println();
Node n = msg.getSOAPBody().getChildNodes().item(0);
// System.out.println("num of attributes is: "+
// n.getAttributes().getLength());
assertTrue(n.getAttributes().getLength() == 1);
}
}
use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.
the class DispatchHelloLiteralTest method getSOAPMessage.
SOAPMessage getSOAPMessage(Source msg) throws Exception {
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
message.getSOAPPart().setContent((Source) msg);
message.saveChanges();
return message;
}
use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.
the class DispatchHello method testHelloRequestResponseSOAPMessage.
public void testHelloRequestResponseSOAPMessage() throws Exception {
Dispatch dispatch = getDispatchSOAPMessage();
assertTrue(dispatch != null);
assertTrue(dispatch instanceof com.sun.xml.ws.client.dispatch.SOAPMessageDispatch);
byte[] bytes = helloSM.getBytes();
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
Source source = makeStreamSource(helloSM);
SOAPMessage message = getSOAPMessage(source);
Object result = dispatch.invoke(message);
// todo:need to check contents
assertTrue(result instanceof SOAPMessage);
}
Aggregations