exception - javax.xml.bind.UnmarshalException: -
i have generated classed using jaxb xsd file
<xs:schema xmlns:tns="http://testwork/" xmlns:xs="http://www.w3.org/2001/xmlschema" version="1.0" targetnamespace="http://testwork/"> <xs:element name="sayhelloworldfrom" type="tns:sayhelloworldfrom"/> <xs:element name="sayhelloworldfromresponse" type="tns:sayhelloworldfromresponse"/> <xs:complextype name="sayhelloworldfrom"> <xs:sequence> <xs:element name="arg0" type="xs:string" minoccurs="0"/> </xs:sequence> </xs:complextype> <xs:complextype name="sayhelloworldfromresponse"> <xs:sequence> <xs:element name="return" type="xs:string" minoccurs="0"/> </xs:sequence> </xs:complextype> </xs:schema>
this generated class
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "sayhelloworldfrom", namespace = "http://testwork/", proporder = { "arg0" }) public class sayhelloworldfrom { protected string arg0; /** * gets value of arg0 property. * * @return * possible object * {@link string } * */ public string getarg0() { return arg0; } /** * sets value of arg0 property. * * @param value * allowed object * {@link string } * */ public void setarg0(string value) { this.arg0 = value; } }
i have soap message this
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tes="http://testwork/"> <soapenv:header/> <soapenv:body> <tes:sayhelloworldfrom> <!--optional:--> <arg0>?</arg0> </tes:sayhelloworldfrom> </soapenv:body> </soapenv:envelope>
i trying format message class sayhelloworldfrom, here example of code
public void unmarshalsoaprequest(inputstream is) throws jaxbexception { jaxbcontext js = jaxbcontext.newinstance(sayhelloworldfrom.class); unmarshaller unmarshaller = js.createunmarshaller(); sayhelloworldfrom sayhelloworldfrom = (sayhelloworldfrom) unmarshaller.unmarshal(is);
but have error in tomcat logs
javax.xml.bind.unmarshalexception: unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"envelope" ). expected elements (none)
what doing wrong? please, newbie :-) thanx in advnance
you trying unmarshall stream contains soap specific information using jaxb context knows nothing soap. able unmarshall middle of soap request.
<tes:sayhelloworldfrom> <!--optional:--> <arg0>?</arg0> </tes:sayhelloworldfrom>
you not supposed write unmarshalsoaprequest
method. normally, you'd either create class implements web service interface or write wsdl , generate code wsdl not xsd.
Comments
Post a Comment