So I was looking into this issue and I found the following in the IS Building Integrations guide under the publishAndWait service:
If you do not specify a receiveDocumentTypeName value, the service uses the first reply document of any type that it receives. (The value of the tag field in the envelope of the reply document must match the tag in the envelope of the published document.) The Integration Server discards any other reply documents it receives.
The idea here would be that you don’t specify the document type for the reply, then you check the type yourself with a branch statement. If it’s the right type, move on with your code; otherwise, handle the error.
All good in theory, but there’s a few snags. First, the document type doesn’t appear anywhere in the envelope field when you have IS 6.0.1 components on both ends. (I didn’t test with 4.x/5.0 components on the reply end, so I’m not sure if they provide this value or not.) You can set the optional envelope fields yourself, so I used pubDistinguishedName and set it to the reply document type name when sending my reply document. This means I can identify the correct reply, but any other documents received are not identifiable by type.
Second, the 6.0.1 error document (pub.publish.notification:error) always throws an exception, even when you leave the receiveDocumentTypeName value blank. I get the following error:
[ISS.0098.9021] Received incorrect document as Reply. Expecting null and received pub.publish.notification:error
Obviously this is wrong - I should be getting that error reply as my returned document, not an exception. I haven’t yet reported this to webMethods as a bug, but unless someone can point out a mistake I’ve made, I’ll be doing so soon.