MultiRef in SOAP XML Response

6
Hi all, In implementing a consumed SOAP webservice, I have created XML Import and XML Export mappings based on the provided WSDL. When I call the webservice and set the loglevels for webservices to Trace, I nicely see a response coming back, wth all the returned attributes I need to have and was expecting. Sadly this XML Import mapping does not reflect the attributes that came back in the response. I think it is related to the fact that the XML I see in the tracing of the webservice response, has a multiRef tag. This multiRef tag is not correctly translated to my response entity, even though it came from it's own WSDL. Does anybody have experience with the multiRef response in a standard Mendix SOAP webservice call?
asked
2 answers
0

Sounds like this should go to a support ticket. You might be able to work around this by accepting the XML response as a string, replacing the multiRef tag, then importing the XML string using an import mapping.

answered
0

I gave the short term solution a go and parsed the response of a SOAP webservice call via Java to a string variabele, see below.

public static String callWebservice(String location, String username, String password, String soapAction, String bodyString,ILogNode logNode) throws HttpException, IOException {

    // build first part of envelope
    String soapEnv = "<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.web.mi.hof.com\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"><soapenv:Header/><soapenv:Body>";
    // build last part of envelope
    String soapEnvEnd = "</soapenv:Body></soapenv:Envelope>";

    // add all together
    RequestEntity soapRequest = new StringRequestEntity(soapEnv + bodyString + soapEnvEnd);

    PostMethod post = new PostMethod(location);
    post.setRequestHeader("Host", new URI(location).getHost());
    post.setRequestHeader("SOAPAction", soapAction);

    post.setRequestEntity(soapRequest);

    HttpClient client = new HttpClient();
    int status = client.executeMethod(post);

    return post.getResponseBodyAsString();

}

After receiving the string response with a regex I searched for the correct value of the tag I was looking for, with this:

String wsResponseString = callWebservice(location,un,pw,soapAction,bodyString,logNode);

String patternString = "<" + lookupTag + " xsi:type=\"xsd:string\">(.+?)</" + lookupTag + ">";

final Pattern pattern = Pattern.compile(patternString);
final Matcher matcher = pattern.matcher(wsResponseString);

// look for the value between the tags
matcher.find();

if (matcher.group(1)!=null){
    String tagValueString = matcher.group(1);   
    return tagValueString;
} else {
     return null;
}
answered