How to build a correct SOAP request with PHP

“Is there a more direct approach where I could write the XML?” By using a SoapVar and setting the encode parameter of the constructor to XSD_ANYXML you can write the raw XML. There should be a way where the WSDL helps build the XML though. You could try something like this: $wsdl = “http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl”; $client … Read more

User authentication in SOAP Webservices

JAAS does not define how the authentication information should look like in SOAP, but WS-Security defines what kind of standardized tokens you can use during client-server exchange (Username+password token / X.509 certificate / SAML token / Kerberos Token). EDIT: With respect to Metro WebService stack, you need (steps taken from here and here): Inject the … Read more

JAXB unmarshall with namespaces and prefix

This can be done without modifying the generated JAXB code using standard SOAPMessage class. I wrote about this here and here It’s a little fiddly but works correctly. Marshalling Farm farm = new Farm(); farm.getHorse().add(new Horse()); farm.getHorse().get(0).setName(“glue factory”); farm.getHorse().get(0).setHeight(BigInteger.valueOf(123)); Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Marshaller marshaller = JAXBContext.newInstance(Farm.class).createMarshaller(); marshaller.marshal(farm, document); SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); soapMessage.getSOAPBody().addDocument(document); ByteArrayOutputStream … Read more

Add SOAP header object using pure JAX-WS

So, it looks like I’ve found possible answer while combining JAX-WS & JAXB related answers from SO (I would really appreciate if somebody experienced in these technologies can check whether following is correct): The obvious thing for me is to add SOAP message handler and alter header of SOAPMessage instance in it: import javax.xml.ws.Binding; import … Read more