I'm having trouble configuring a spring-ws client to talk to the corresponding servlet. The current issue is that running connection.call(message, endpoint) produces the following output:
I'm assuming this is related to either a malformed message, or an incorrect configuration setting for the servlet. I'm testing against apache tomcat 5.5. Here's the client code:Code:Mar 7, 2008 8:59:24 AM com.sun.xml.messaging.saaj.soap.MessageImpl saveChanges SEVERE: SAAJ0540: Error during saving a multipart message java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
Which produces the soap request:Code:try { // Create a SOAPConnection SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = factory.createConnection(); // Create a SOAPMessage MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("xsd","http://www.w3.org/2001/XMLSchema"); envelope.addNamespaceDeclaration("xsi","http://www.w3.org/2001/XMLSchema-instance"); envelope.addNamespaceDeclaration("enc","http://schemas.xmlsoap.org/soap/encoding/"); envelope.addNamespaceDeclaration("env","http://schemas.xmlsoap.org/soap/envelope/"); envelope.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/"); SOAPHeader header = envelope.getHeader(); SOAPBody body = envelope.getBody(); header.detachNode(); // Create a SOAPBodyElement Name bodyName = envelope.createName("PersonLookupRequest", "p", "http://localhost:8080/pl/schemas"); SOAPBodyElement bodyElement = body.addBodyElement(bodyName); bodyElement.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); bodyElement.setAttribute("xsi:schemaLocation", "http://localhost:8080/pl/schemas pl.xsd"); // Insert Content SOAPElement symbol = bodyElement.addChildElement(envelope.createName("Name", "p", "http://localhost:8080/pl/schemas")); symbol.addTextNode("p:SUNW"); Name typeName = envelope.createName("type","xsi","string"); symbol.addAttribute(typeName, "xsi:string"); // Create an endpint point which is either URL or String type URL endpoint = new URL("http://localhost:8080/PersonLookup"); // Check the input System.out.println(message.getSOAPPart().getEnvelope()); // Send a SOAPMessage (request) and then wait for SOAPMessage (response) SOAPMessage response = connection.call(message, endpoint); System.out.println("\nRESPONSE:\n"); // Create the transformer TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); // Extract the content of the reply Source sourceContent = response.getSOAPPart().getContent(); // Set the output for the transformation StreamResult result = new StreamResult(System.out); transformer.transform(sourceContent, result); System.out.println(); // Close the SOAPConnection connection.close(); } catch (Exception e) { System.out.println(e.getMessage()); }
The schema from pl.xsd:Code:<?xml version="1.0" encoding="UTF-16"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><p:PersonLookupRequest xmlns:p="http://localhost:8080/pl/schemas" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost:8080/pl/schemas pl.xsd"><p:Name xmlns:xsi="string" xsi:type="xsi:string">p:SUNW</p:Name></p:PersonLookupRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
Help?Code:<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://localhost:8080/pl/schemas" xmlns="http://localhost:8080/pl/schemas" elementFormDefault="qualified"> <xs:element name="PersonLookupRequest"> <xs:complexType> <xs:all> <xs:element name="Name" type="xs:string"/> </xs:all> </xs:complexType> </xs:element> <xs:element name="PersonLookupResponse"> <xs:complexType> <xs:all> <xs:element name="Name" type="xs:string"/> <xs:element name="Email" type="xs:string"/> </xs:all> </xs:complexType> </xs:element> </xs:schema>


Reply With Quote