Reputation: 105
In SoapUI I've got this exception
<faultstring>Unmarshalling Error: unexpected element (uri:"http://ws.soap.rd.pl", local:"User"). Expected elements are <{}User></faultstring>
I really do not know wy I've got this issue. I've tried trip gave in Stack but still cant find the answer. @XmlRootElement is added so I'm really confused.
request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.soap.rd.pl/" xmlns:ws1="http://ws.soap.rd.pl">
<soapenv:Header/>
<soapenv:Body>
<ws:updateUser>
<!--Optional:-->
<ws1:User>
<ID>?</ID>
<!--Optional:-->
<Imie>?</Imie>
<!--Optional:-->
<Nazwisko>?</Nazwisko>
<!--Optional:-->
<ws1:Adres>
<!--Optional:-->
<id>?</id>
<!--Optional:-->
<Ulica>?</Ulica>
<!--Optional:-->
<Miasto>?</Miasto>
</ws1:Adres>
</ws1:User>
</ws:updateUser>
</soapenv:Body>
</soapenv:Envelope>
my dto:
@XmlRootElement(name = "Adres", namespace = "http://ws.soap.rd.pl")
@XmlAccessorType(XmlAccessType.FIELD)
public class AddressDto {
@XmlElement(name = "id", required = false)
public Long id;
@XmlElement(name = "Ulica", required = false)
public String street;
@XmlElement(name = "Miasto", required = false)
public String city;
@Override
public String toString() {
return "AddressDto [street=" + street + ", city=" + city + "]";
}
}
and the second one:
@XmlRootElement(name = "User", namespace = "http://ws.soap.rd.pl")
@XmlAccessorType(XmlAccessType.FIELD)
public class UserDto {
@XmlElement(name = "ID")
public long id;
@XmlElement(name = "Imie", required = false)
public String firstName;
@XmlElement(name = "Nazwisko", required = false)
public String lastName;
@XmlElement(name = "Adres", required = false)
public AddressDto addressDto;
@Override
public String toString() {
return "UserDto [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", addressDto=" + addressDto + "]";
}
}
if you need my webService definition:
@WebService(endpointInterface = "userService", serviceName = "userService", name = "userServive")
public interface UserService {
@WebMethod
public void updateUser(@WebParam(name = "User") UserDto user);
}
Upvotes: 1
Views: 1484
Reputation: 43671
Try adding the targetNamespace
to your @WebParam
:
@WebMethod
public void updateUser(
@WebParam(name = "User", targetNamespace = "http://ws.soap.rd.pl")
UserDto user);
Upvotes: 1