我在我的WSDL的模式限制,這樣的定義:gSOAP的正則表達式驗證
<complexType name="xxxXXX">
<attribute name="state" use="optional">
<simpleType>
<restriction base="xs:string">
<pattern value="((\-1)|[0-5])(;((\-1)|[0-5]))*"/>
</restriction>
</simpleType>
</attribute>
</complexType>
但是,當我一個請求與狀態=「」 gSOAP的接受它。我看到我必須定義函數fsvalidate
(這裏是https://www.genivia.com/doc/databinding/html/),但似乎從未調用(不觸發斷點)。 Futhermore,生成gSOAP的代碼不包含正則表達式,即使工具wsdl2h產生這樣的:
class ns1__xxxXXX
{ public:
@/// Content pattern is "((\\-1)|[0-5])(;((\\-1)|[0-5]))*".
std::string
*state 0; ///< Optional attribute.
/// A handle to the soap struct that manages this instance (automatically set).
struct soap *soap ;
};
也許我錯過了一代一些選擇,但我沒有找到wsdl2h anythink(https://linux.die.net/man/1/wsdl2h ),也不soapcpp2
其他信息:
我搜索fsvalidate在gSOAP的的生成的代碼,我發現:
#ifndef WITH_LEANER
if (pattern && soap->fsvalidate && (soap->error = soap->fsvalidate(soap, pattern, s)))
return NULL;
#endif
但是,它似乎總是用NULL模式調用。(!(t = soap_string_in(soap, 1, 0, -1, NULL)))
。我使用gSOAP 2.8.23。
- 編輯:
我跟着@亞歷克斯的意見,以從中提取複雜類型是這樣的類型:
<xs:simpleType name="stateType">
<xs:restriction base="xs:string">
<xs:pattern value="((\-1)|[0-5])(;((\-1)|[0-5]))*"/>
</xs:restriction>
</xs:simpleType>
<complexType name="xxxXXX">
<attribute name="state" type="tns:stateType" use="optional" />
</complexType>
而且wsdl2h似乎產生了好事:
/// Content pattern is "((\\-1)|[0-5])(;((\\-1)|[0-5]))*".
typedef std::string ns1__stateType "((\\-1)|[0-5])(;((\\-1)|[0-5]))*";
class ns1__xxxXXX
{ public:
/// Attribute "state" of XSD type "http://new.webservice.namespace":stateType.
@ns1__stateType* state 0;
但gsoap生成的最終類型是std :: string:
class SOAP_CMAC ns1__xxxXXX
{
public:
std::string *state;
,當然,它不驗證正則表達式。
感謝您的回答,請參閱我的編輯以獲取更多信息。 – VSA
我將gsoap的版本更新到了2.8.44,現在它可以正常工作。 – VSA