我在http协议请求消息上构建了一个soap,如下所示:
<HttpClientRq>
<header>
<parameter name="Content-Type" value="text/xml"/>
</header>
<body>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://www.soapui.org/sample/">
<soapenv:Header/>
<soapenv:Body>
<sam:login>
<username>Login</username>
<password>Login123</password>
</sam:login>
</soapenv:Body>
</soapenv:Envelope>
</body>
</HttpClientRq>
Run Code Online (Sandbox Code Playgroud)
我使用SOAPUI工具创建一个模拟服务操作,登录.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://www.soapui.org/sample/">
<soapenv:Header/>
<soapenv:Body>
<sam:login>
<username>Login</username>
<password>Login123</password>
</sam:login>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
我发送上面的请求消息,SOAPUI管理成功接收请求消息.但不幸的是,它遇到如下错误:
ERROR [SoapUI] An error occurred [org.apache.xmlbeans.XmlException: Missing/Invalid SOAP Envelope, expecting [{http://schemas.xmlsoap.org/soap/envelope/}Envelope]], see error log for details
2016-07-26 17:31:57,943 ERROR [errorlog] com.eviware.soapui.impl.wsdl.mock.DispatchException: org.apache.xmlbeans.XmlException: Missing/Invalid SOAP Envelope, expecting [{http://schemas.xmlsoap.org/soap/envelope/}Envelope]
com.eviware.soapui.impl.wsdl.mock.DispatchException: org.apache.xmlbeans.XmlException: Missing/Invalid SOAP Envelope, expecting [{http://schemas.xmlsoap.org/soap/envelope/}Envelope]
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchPostRequest(WsdlMockDispatcher.java:241)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchRequest(WsdlMockDispatcher.java:113)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:142)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:604)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) …Run Code Online (Sandbox Code Playgroud) 我在这里需要帮助的一个基本问题。每当在父组件上调用this.setState时,将呈现所有子组件。如果我有大量的子组件,这将导致性能问题。
让我们举个例子
父组件
handleToggleTick() {
const newObj = Object.assign({}, this.state, { iconName: ''});
this.setState({
iconName: newObj.iconName,
});
}
render() {
return(
<ChildComponentA iconName={this.state.iconName} toggleTick={() => this.handleToggleTick}></ChildComponentA>
<ChildComponentB></ChildComponentA>
<ChildComponentC></ChildComponentA>
)
}
Run Code Online (Sandbox Code Playgroud)
根据上面的示例,每当从childcomponentA调用handleToggleTick时,都会为新的iconName调用setState。我想要的是,因为props.iconName与之相关,所以只有ChildComponentA仅获得一个渲染,而与childcomponentB和childcomponentC没有关系。
我知道有一个选项可以检查childcomponent中的shouldComponentUpdate以防止其渲染。但是,想象一下我有超过100个childcomponent,编写超过100次的shouldComponentUpdate方法是否会令人沮丧?
我在这里需要帮助,请指教!