JeffreySu/WeiXinMPSDK · error · WeixinException
RequestMessage转换出错!可能是InfoType不存在!,XML:
Error message
RequestMessage转换出错!可能是InfoType不存在!,XML:{0} What it means
Inside GetRequestEntity, the catch (ArgumentException) block rethrows as WeixinException 'RequestMessage转换出错!可能是InfoType不存在!' with the full XML. EntityHelper.FillEntityWithXml throws ArgumentException when the parsed requestMessage type cannot be filled from the XML (missing/invalid fields), so this indicates the XML shape did not match the mapped request message class.
Solutions
- Read ex.InnerException and the XML in the message to see exactly which field failed to fill.
- Upgrade Senparc.Weixin.Open so entity classes match the current WeChat schema.
- Verify you are passing the correctly decrypted component push XML (post-WxCryptUtil decryption) to GetRequestEntity.
Example fix
// before
var doc = XDocument.Parse(encryptedBody);
var msg = RequestMessageFactory.GetRequestEntity(doc);
// after
var doc = XDocument.Parse(decryptor.Decrypt(xml)); // decrypt first
try { var msg = RequestMessageFactory.GetRequestEntity(doc); }
catch (WeixinException ex) { logger.LogWarning(ex, "Bad push XML: {Xml}", ex.Message); } Defensive patterns
Strategy: try-catch
Validate before calling
if (doc.Root?.Element("InfoType") == null)
throw new InvalidOperationException("Not a component push XML"); Type guard
bool IsComponentPushXml(XDocument d) => d.Root?.Element("InfoType") != null && d.Root?.Element("AppId") != null; Try / catch
try { var msg = RequestMessageFactory.GetRequestEntity(doc); }
catch (WeixinException ex)
{ logger.LogWarning(ex, "XML fill failed: {Xml}", doc); return Content("success"); } Prevention
- Decrypt the component push XML before passing it to the factory.
- Verify the SDK entity classes match the current WeChat push schema (upgrade regularly).
- Log the offending XML included in the WeixinException message for diagnosis.
When it happens
Trigger: InfoType mapped to a request class but FillEntityWithXml finds the XML fields incompatible with the entity's properties (ArgumentException), e.g. WeChat changed the payload schema or a wrong document is passed (not component push XML).
Common situations: WeChat payload schema drift on older SDK versions; passing a non-component push XML (e.g. normal public-account message) into the third-party factory; corrupted or double-encrypted XML reaching the factory.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- InfoType: 在RequestMessageFactory中没有对应的处理程序!
- RequestMessage转换出错!可能是MsgType不存在!,XML:
- RequestMessage转换异常!InfoType类型存在的情况下无法处理!,XML:
- RequestMessage转换出错!MsgType和InfoType都不存在!,XML:
- MsgType: 在ResponseMessageFactory中没有对应的处理程序!
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/965b4beef7731ba3.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.Open/Senparc.Weixin.Open/RequestMessageFactory.cs:126
requestMessage = new RequestMessage3rdWxaAuth();
break;
case RequestInfoType.notify_3rd_wxa_wxverify:
requestMessage = new RequestMessage3rdWxaWxVerify();
break;
case RequestInfoType.order_path_apply_result_notify:
requestMessage = new RequestMessageOrderPathApplyResultNotify();
break;
case RequestInfoType.order_path_audit_result_notify:
requestMessage = new RequestMessageOrderPathAuditResultNotify();
break;
default:
throw new UnknownRequestMsgTypeException(string.Format("InfoType:{0} 在RequestMessageFactory中没有对应的处理程序!", infoType), new ArgumentOutOfRangeException());//为了能够对类型变动最大程度容错(如微信目前还可以对公众账号suscribe等未知类型,但API没有开放),建议在使用的时候catch这个异常
}
EntityHelper.FillEntityWithXml(requestMessage, doc);
}
catch (ArgumentException ex)
{
throw new WeixinException(string.Format("RequestMessage转换出错!可能是InfoType不存在!,XML:{0}", doc.ToString()), ex);
}
return requestMessage;
}
/// <summary>
/// 获取XDocument转换后的IRequestMessageBase实例。
/// 如果MsgType不存在,抛出UnknownRequestMsgTypeException异常
/// </summary>
/// <returns></returns>
public static IRequestMessageBase GetRequestEntity(string xml)
{
return GetRequestEntity(XDocument.Parse(xml));
}
/// <summary>
/// 获取XDocument转换后的IRequestMessageBase实例。View on GitHub (pinned to be573f6f94)