I am working on a web service project that uses Axis 1.4. The stub and classes are built from the Eclipse Generate Client tool and a provided WSDL. I am able to upload files without issue but I am unable to download files. Requested files are sent back using MTOM. My Request and Responses are formatted correctly but I am getting the following error:
Axis Fault string: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
I have set the following but it does not appear to help:
getStub()._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT,Call.ATTACHMENT_ENCAPSULATION_FORMAT_MTOM);
Any help would be great appreciated on how to resolve this and be able to access the attachment.
Request:
<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>
<getFile xmlns="endpoint">
<input>
<userName>USERNAME</userName>
<passWord>PASSWORD</passWord>
<fileName>FILENAME</fileName>
</input>
</getFile>
</soapenv:Body>
</soapenv:Envelope>
Response:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<getResponse xmlns:a="http://www.w3.org/2005/05/xmlmime" xmlns="endpoint">
<output>
<fileData>
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:FILEREFERENCENUMBER#apache.org"/>
</fileData>
</output>
</getResponse>
</soapenv:Body>
</soapenv:Envelope>
My Java project use JAX-WS to create SOAP Webservice. Client is another application send SOAP request to our SOAP Webservice, our SOAP WS receive request, process it and return SOAP response to client.
The SOAP message of client has structure:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:something">
<soapenv:Header/>
<soapenv:Body>
<urn:createAnimal>
<urn:animalData>
<urn:name>Tiger</urn:name>
</urn:animalData>
</urn:createAnimal>
</soapenv:Body>
</soapenv:Envelope>
But the server only support message with structure
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="/com/zoo/zoo/model/service/common/types/" xmlns:com="/com/zoo/zoo/model/view/common/">
<soapenv:Header/>
<soapenv:Body>
<typ:createAnimal>
<typ:animalData>
<!--Optional:-->
<com:name>Tiger</com:firstname>
</typ:animalData>
</typ:createAnimal>
</soapenv:Body>
</soapenv:Envelope>
When client send request to my SOAP Webservice, it receive error:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault>
<faultcode>env:Client</faultcode>
<faultstring>Unknown method</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>
I know the reason. Because the namespace of client is xmlns:urn="urn:something" and namespace in supported request of my SOAP service is xmlns:typ="/com/zoo/zoo/model/service/common/types/" xmlns:com="/com/zoo/zoo/model/view/common/". I can not change request structure from client(include namespace). How can I change namespace of my SOAP WS so that it can support namespace xmlns:urn="urn:something" with JAX-WS
Request from my Web Service looked like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://mywebservice.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:something>
Now, it looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:jax="http://mywebservice.com/">
<soapenv:Header/>
<soapenv:Body>
<jax:something>
What´s the difference between jax and ser? I get the same answers and apparently nothing has changed.
I am facing one weird issue in web services. Functionality is working fine,but the response have some unneccessary namespace to the response element, That prefix is not at all defined in the wsdl or stubs. How to remove the unneccessary prefixes in the response element, that namespace is not at all defined in the WSDL. Please help me out to resolve.
Output:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<p30:realTimeWSProviderResponse xmlns:p30="http://eh.actimize.com">
<requestId/>
<searchDefinitionId/>
<generateAlert/>
Expected Output:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<RealTimeWSProviderResponse xmlns="http://eh.actimize.com">
<requestId xmlns=""/>
<searchDefinitionId xmlns=""/>
<generateAlert xmlns=""/>
<enableSuppression xmlns=""/>
<partyType xmlns=""/>
<partyKey xmlns=""/>
<names xmlns="">
I got little Problems with my generated code:
here the XML Structure that i need to have:
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<soapenv:Envelope xmlns:v1="http://openclinica.org/ws/study/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="soapenc" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-27777511" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>xxxx</wsse:Username>
<wsse:Password type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxxxxxx</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<v1:listAllRequest/>
</soapenv:Body>
</soapenv:Envelope>
and here´s my Code that i have done:
declarePrefix("v1", NAMESPACE);
getBody().addTextNode(null, METHOD_NAME, "?");
XMLParentNode security = new XMLParentNodeImpl(HEADER_NAMESPACE, "Security");
security.addAttribute(HEADER_NAMESPACE,"mustUnderstand", "1");
XMLParentNode usernameToken = new XMLParentNodeImpl(UNT_NAMESPACE, "UsernameToken");
usernameToken.addTextNode(null, "wsse:Username", "root");
usernameToken.addTextNode(PASSTYPE, "wsse:Password", Constants.OC_PASSWORD);
security.addElement(usernameToken);
getHeader().addElement(security);
but the output looks like:
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<soapenv:Envelope xmlns:v1="http://openclinica.org/ws/study/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<n0:Security n0:mustUnderstand="1" xmlns:n0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<n1:UsernameToken xmlns:n1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>xxxx</wsse:Username>
<n2:wsse:Password xmlns:n2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxxxxxx</n2:wsse:Password>
</n1:UsernameToken>
</n0:Security>
</soapenv:Header>
<soapenv:Body>
<listAllRequest>?</listAllRequest>
</soapenv:Body>
</soapenv:Envelope>
you see i have some trouble with the lines
<n0:Security....
<n1:UsernameToken...
<n2:wsse:Password...
how can i change the n0,n1 etc... not just in the beginn of the line specialy on the tags like n0:mustUnderstand="1"
i tryed to declare prefixes etc but nothing changes tis object.
Can someone tell with what method i can change this things
Thanks a lot for helping
Christian
for all intrestet Users, i solved it that way:
declarePrefix("v1", NAMESPACE);
declarePrefix("soapenc", "soapenc");
getBody().addTextNode(null, METHOD_NAME, "?");
XMLParentNode security = new XMLParentNodeImpl(null, "wsse:Security");
security.declarePrefix("wsse", HEADER_NAMESPACE);
security.addAttribute(HEADER_NAMESPACE,"mustUnderstand", "1");
XMLParentNode usernameToken = new XMLParentNodeImpl(null, "wsse:UsernameToken");
usernameToken.declarePrefix("wsu", UNT_NAMESPACE);
usernameToken.addAttribute(null, "wsu:Id", "UsernameToken-27777511");
usernameToken.addTextNode(null, "wsse:Username", Constants.OC_Username);
usernameToken.addTextNode(null, "wsse:Password", Constants.OC_PASSWORD);
security.addElement(usernameToken);
getHeader().addElement(security);
the results not 100% simular to my outgoing code, but the request are working :)