Hi,

I've been forced to get Java to work with a WSDL/SOAP web service. I admit that I don't really understand the nuts and bolts but I've managed to work my way around it.

What I've done so far is access services just like you would through a web browser, for example:

https://myserver/webservices/insertP...ate=2010-09-29

This has worked for everything up until this particular web service as I get class cast exceptions returned by the server on the date field if I manually type it in. I have a PHP example that works perfectly I just can't get java to do the same.

So I have to use a full blown SOAP client. The problem is now I'm getting the error:
Message part {https://myserver/webservices/insertPhone}insertPhoneResponse was not recognized. (Does it exist in service WSDL?)

Here is the code in question:

PHP Code:
try {
            
SOAPConnectionFactory sfc SOAPConnectionFactory.newInstance();
            
SOAPConnection connection sfc.createConnection();

            
MessageFactory mf MessageFactory.newInstance();
            
SOAPMessage sm mf.createMessage();

            
SOAPHeader sh sm.getSOAPHeader();
            
SOAPBody sb sm.getSOAPBody();
            
sh.detachNode();

            
QName bodyName = new QName(
                    
"https://myserver/webservices/insertPhone",
                    
"insertPhoneResponse");
            
SOAPBodyElement bodyElement sb.addBodyElement(bodyName);
           
            
// Username
            
QName qn = new QName("username");
            
SOAPElement value bodyElement.addChildElement(qn);
            
value.addTextNode("blah");
            
// Password
            
qn = new QName("password");
            
value bodyElement.addChildElement(qn);
            
value.addTextNode("blah");

           
// notes
            
qn = new QName("notes");
            
value bodyElement.addChildElement(qn);
            
value.addTextNode("testing please ignore");

            
// Date
            
qn = new QName("date");
            
value bodyElement.addChildElement(qn);
            
value.addTextNode("2010-09-29T15:32:11+00:00");//The php code for this field is date('c')

            
System.out.println("\n Soap Request:\n");
            
sm.writeTo(System.out);
            
System.out.println();

            
URL endpoint = new URL(
                    
"https://myserver/webservices/insertPhone");
            
SOAPMessage response connection.call(smendpoint);
            
connection.close();
            
System.out.println();
            
System.out.println("Response: ");
            
// Create a transformer
            
TransformerFactory tf TransformerFactory.newInstance();
            
Transformer transformer tf.newTransformer();
            
// Retrieve content of the response
            
Source content response.getSOAPPart().getContent();
            
// Display it on the console
            
StreamResult result = new StreamResult(System.out);
            
transformer.transform(contentresult);
            
System.out.println();
            
System.out.println(new java.util.Date());
            
        } catch (
Exception ex) {
            
ex.printStackTrace();
        } 
Any hints would be appreciated, I'm guessing its an endpoint or body qname problem but I've tried lots of permutations to no effect.