I'm a newbie developing Web Services. I've created java classes from XSD using xjc command (command line "xjc ....\MySchema.xsd").
<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. -->
<s:schema elementFormDefault="qualified" targetNamespace="http://SAS.Servicios/" xmlns:s="http://ift.tt/tphNwY">
<s:element name="S014">
<s:complexType>
<s:sequence>
<s:element name="MensEntrada">
<s:complexType mixed="true">
<s:choice maxOccurs="unbounded" minOccurs="0">
<s:any processContents="lax"/>
</s:choice>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="S014Response">
<s:complexType>
<s:sequence>
<s:element name="MensSalida">
<s:complexType mixed="true">
<s:choice maxOccurs="unbounded" minOccurs="0">
<s:any processContents="lax"/>
</s:choice>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
xsd app generates some classes,
S014.java
...
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"mensEntrada"
})
@XmlRootElement(name = "S014")
public class S014 {
@XmlElement(name = "MensEntrada", required = true)
protected S014 .MensEntrada mensEntrada;
public S014 .MensEntrada getMensEntrada() {
return mensEntrada;
}
public void setMensEntrada(S014 .MensEntrada value) {
this.mensEntrada = value;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"content"
})
public static class MensEntrada {
@XmlMixed
@XmlAnyElement(lax = true)
protected List<Object> content;
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
}
}
S014Response.java
...
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"mensSalida"
})
@XmlRootElement(name = "S014Response")
public class S014Response {
@XmlElement(name = "MensSalida", required = true)
protected S014Response.MensSalida mensSalida;
public S014Response.MensSalida getMensSalida() {
return mensSalida;
}
public void setMensSalida(S014Response.MensSalida value) {
this.mensSalida = value;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"content"
})
public static class MensSalida {
@XmlMixed
@XmlAnyElement(lax = true)
protected List<Object> content;
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
}
}
ObjectFactory.java
...
@XmlRegistry
public class ObjectFactory {
public ObjectFactory() {
}
public S014Response createS014Response() {
return new S014Response();
}
public S014 createS014() {
return new S014();
}
public S014Response.MensSalida createS014ResponseMensSalida() {
return new S014Response.MensSalida();
}
public S014 .MensEntrada createS014MensEntrada() {
return new S014 .MensEntrada();
}
}
I need to create a Web Service to read an incoming message "MensEntrada" and returns "MensSalida".
I was trying this:
...
@WebService (serviceName = "S014Service", portName="S014ServiceSoap", targetNamespace = "http://SAS.Servicios/")
public class S014Service extends AcceptMessage {
public S014Service(WebServiceReceiver webServiceReceiver) {
super(webServiceReceiver);
}
@WebMethod(action = "S014")
public S014Response S014(@WebParam(name = "MensEntrada") S014 param) {
String response = param.getMensEntrada().toString();
response = response + "!!!";
S014Response ms = new S014Response();
return ms;
}
}
But it doesn't work. How can I read MensEntrada? How can I write MensSalida?
Thanks in advance!!
Aucun commentaire:
Enregistrer un commentaire