Axis consuming .Net Webservice
Goddav..Jeg har en lavet en Java Applikation der skal tilgå en .net Webservice. Men kan ikke helt få det til at virke.
Webservicen jeg skal tilgå ser således ud.
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CreateUserAndEmailPass xmlns="http://???.???.???.???/?????????/???/">
<email>string</email>
<firstName>string</firstName>
<lastName>string</lastName>
<countryID>int</countryID>
<phone>string</phone>
</CreateUserAndEmailPass>
</soap12:Body>
</soap12:Envelope>
Min Java metode ser således ud. Jeg bruger Axis til at tilgå servicen.
public boolean createUser(String email, String firstName, String lastName, String phone)
{
boolean result = false;
functionName = "CreateUserAndEmailPass";
soapAction = qName + functionName;
call.setOperationName(new QName(qName, functionName));
call.setReturnType(XMLType.XSD_BOOLEAN);
call.setReturnClass(Boolean.class);
call.addParameter(new QName(qName,"email"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName(qName,"firstName"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName(qName,"lastName"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName(qName,"countryID"), XMLType.XSD_INT, ParameterMode.IN);
call.addParameter(new QName(qName,"phone"), XMLType.XSD_STRING, ParameterMode.IN);
call.setSOAPActionURI(soapAction);
try {
result = (Boolean) call.invoke(
new Object[] {
email,
firstName,
lastName,
/** TODO CountryID bliver hardcoded **/
187,
phone
}
);
} catch (Exception e) {
e.printStackTrace();
System.err.println(e.toString());
}
return result;
}
Men Webservicen melder denne exception, når jeg prøver at tilgå den.
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
faultSubcode:
faultString: Server was unable to read request. ---> There is an error in XML document (1, 584). ---> Input string was not in a correct format.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:Server was unable to read request. ---> There is an error in XML document (1, 584). ---> Input string was not in a correct format.
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at webservice.Webservice.createUser(Webservice.java:56)
at gui.whiteGui.GuiController.init(GuiController.java:84)
at core.Controller.<init>(Controller.java:122)
at MainApplet.init(MainApplet.java:41)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Bruger jeg derimod XSD_STRING på countryID, melder den ingen fejl og virker som den skal. Er der nogle der har en fornuftig forklaring på dette. Det er første gang jeg bruger Axis, så har sikkert lavet en brainfart et eller andet sted :D