Hi,
I'm using Axis 1.1 to use a set of .NET Web serverices. Please excuse any
innacuracies as I've only really started with web services in the last couple of days.
So far, I have managed to create an Axis client that talks to a .NET service, but I
get the following exception thrown:
Does anybody have any ideas why or when this is thrown? It's baffling me. I've
looked around at various resources and they suggest using either RPC/literal or
DOCUMENT/literal and have tried this with no better results.
I've included a whole bunch of stuff below that might be of some help, and would
appreciate any ideas at all. Many thanks in advance....
Robin
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT
expected, in something it was trying to deserialize.
at
org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:189)
at
org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:963)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)
at
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
at org.apache.axis.client.Call.invoke(Call.java:2272)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at
uk.co.landmarkinfo.stl.busdel.UserBD.validateWebServicesUserLogin(UserBD.java:127)
at
uk.co.landmarkinfo.stl.busdel.UserBDTest.testValidateWebServicesUserLogin(UserBDTest.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
......
My Source Code :
public boolean validateWebServicesUserLogin(int branchID, String username, String
password) {
try {
log.debug("Executing ...");
System.out.println("Running...");
//String endpoint = "http://www.company.com/xxx/login/wslogin.asmx";
String endpoint = "http://127.0.0.1:8080/xxx/login/wslogin.asmx";
Service service = new Service();
Call call = (Call) service.createCall();
log.debug("step 1");
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setSOAPActionURI("http://anyuri.org/login/Service1/Login");
//call.setOperationStyle("document");
//call.setOperationUse("literal");
log.debug("step 2");
call.setOperationName(new QName("http://anyuri.org/login/Service1",
"Login"));
call.addParameter("intAccNo", XMLType.XSD_INT, ParameterMode.IN);
call.addParameter("strUserName", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("strPassword", XMLType.XSD_STRING, ParameterMode.IN);
//call.setReturnType(XMLType.XSD_STRING);
//call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
//call.setProperty(Call.SOAPACTION_URI_PROPERTY,
"http://anyuri.org/login/Service1/Login");
call.invoke("http://anyuri.org/login/Service1", "Login", new Object[] {
new Integer(branchID), username, password } );
log.debug("step 4");
log.debug("<br>Sent " + branchID + ", " + username + ", " + password);
} catch (ServiceException e) {
log.debug("ServiceException: " + e.getMessage());
} catch (MalformedURLException mue) {
log.debug("MalformedURLException: " + mue.getMessage());
} catch (org.apache.axis.AxisFault af) {
log.debug("AxisFault: " + af.dumpToString());
}
return true;
}
My Axis client sends :
POST /stl/login/wslogin.asmx HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept:
application/soap+xml, application/dime, multipart/related, text/* User-Agent: Axis/1.1
Host: www.company.com Cache-Control: no-cache Pragma: no-cache SOAPAction:
"http://anyuri.org/login/Service1/Login" Content-Length: 574 <?xml version="1.0"
encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:Login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://anyuri.org/login/Service1">
<intAccNo xsi:type="xsd:int">123</intAccNo>
<strUserName xsi:type="xsd:string">robin</strUserName>
<strPassword xsi:type="xsd:string">mypassword</strPassword>
</ns1:Login>
</soapenv:Body>
</soapenv:Envelope>
And the following is returned :
HTTP/1.1 200 OK Server: Microsoft-IIS/5.0 Date: Thu, 07 Oct 2004 15:53:24 GMT
X-Powered-By: ASP.NET X-AspNet-Version: 1.1.4322 Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8 Content-Length: 465 <?xml version="1.0"
encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoginResponse xmlns="http://anyuri.org/login/Service1">
<LoginResult>
<UserDetails xmlns="">
<OPSTATUS1>2</OPSTATUS1>
<OPSTATUS2>STLSOP Invalid Login</OPSTATUS2>
</UserDetails>
</LoginResult>
</LoginResponse>
</soap:Body>
</soap:Envelope>
====================================================================
This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this e-mail and you are not a named
addressee, please inform Landmark Information Group on 01491 413030
and then delete the e-mail from your system. If you are not a named
addressee you must not use, disclose, distribute, copy, print or rely
on this e-mail. This email and any attachments have been scanned for
viruses and to the best of our knowledge are clean. To ensure
regulatory compliance and for the protection of our clients and
business, we may monitor and read e-mails sent to and from our
servers.