- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Java 连接(但没有成功)到以下 WS:
我尝试使用soapui但没有成功。尝试了基本和 NTLM 身份验证,但我总是收到以下错误:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
</s:Header>
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:InvalidSecurity</faultcode>
<faultstring xml:lang="en-US">An error occurred when verifying security for the message.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>
此 Web 服务的官方说明显示了以下使用 C# 进行连接的示例。我还没有测试过这个,但我认为它工作正常。
try {
var proxy = new ChannelFactory<ServiceReferenceWCF.ITerytWs1>("custom");
proxy.Credentials.UserName.UserName = login;
proxy.Credentials.UserName.Password = haslo;
var result = proxy.CreateChannel();
var test = result.CzyZalogowany(); // should return true if connected correctly
} catch (Exception ex) { }
以及以下设置:
<client>
<endpoint address="https://uslugaterytws1.stat.gov.pl/TerytWs1.svc" binding="customBinding" bindingConfiguration="custom" contract="ServiceReference1.ITerytWs1" name="custom" />
</client>
<bindings>
<customBinding>
<binding name="custom">
<security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</security>
<textMessageEncoding messageVersion="Soap11WSAddressing10" />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" />
</binding>
</customBinding>
</bindings>
所以我尝试通过以下方式使用 Java 进行连接:
public static void main(String[] args) {
try {
final String wsdlResourcePath = "wsdl/jaxb/teryt/terytws1.wsdl";
final String url = "https://uslugaterytws1test.stat.gov.pl/TerytWs1.svc";
ITerytWs1 teryt = createSoapEndpoint((wsdlLocation) -> new TerytWs1(wsdlLocation).getCustom(), wsdlResourcePath, url);
System.out.println(teryt.czyZalogowany());
} catch (Exception e) { }
}
private static <SOAP> SOAP createSoapEndpoint(SoapCreator<SOAP> soapCreator, String wsdlResourcePath, String url) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL wsdlLocation = cl.getResource(wsdlResourcePath);
SOAP soap = soapCreator.create(wsdlLocation);
BindingProvider provider = (BindingProvider) soap;
Map<String, Object> context = provider.getRequestContext();
context.put(BindingProvider.USERNAME_PROPERTY, "TestPubliczny");
context.put(BindingProvider.PASSWORD_PROPERTY, "1234abcd");
context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
return soap;
}
不幸的是,代码在调用“teryt.czyZalogowany()”期间卡住。没有超时 - 任何事情,只是永远处理这一行,或者被阻止。
我的 Java 代码产生以下警告消息:
WARNING: WSP0075: Policy assertion "{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}SignedSupportingTokens" was evaluated as "UNKNOWN". lip 27, 2017 11:58:35 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives WARNING: WSP0075: Policy assertion "{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}TransportBinding" was evaluated as "UNKNOWN". lip 27, 2017 11:58:35 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives WARNING: WSP0075: Policy assertion "{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Trust10" was evaluated as "UNKNOWN". lip 27, 2017 11:58:35 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives WARNING: WSP0075: Policy assertion "{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Wss11" was evaluated as "UNKNOWN". lip 27, 2017 11:58:35 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives WARNING: WSP0075: Policy assertion "{http://www.w3.org/2006/05/addressing/wsdl}UsingAddressing" was evaluated as "UNKNOWN". lip 27, 2017 11:58:35 AM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".
也许有人对此类问题了解更多,或者能够使用自己的配置立即连接到此 WS - 目前我没有任何线索可能会出现问题,并且我看到了“浪费时间”的观点在我面前......所以请帮忙。
最佳答案
请启用寻址功能:
TerytWs1 teryt = new TerytWs1();
//teryt.setHandlerResolver(new HeaderHandlerResolver());
WebServiceFeature wsAddressing = new AddressingFeature(true);
ITerytWs1 client = teryt.getCustom(wsAddressing);
关于java - 与 TERYT 集成 - 波兰政府网络服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45347681/
注意!! 了解波兰语或任何其他具有强烈屈曲性的自然语言,最好是带有格系统(例如德语),将有很大帮助回答这个问题。特别是,波兰语变格系统与其他斯拉夫语言系统非常相似,例如:俄语、捷克语、塞尔维亚语等。
我正在用 C 开发一个嵌入式应用程序,它必须符合 MISRA标准。它将涉及使用包含波兰语符号 (ąęćłńśźż) 的字符串。我尝试使用八进制/十六进制转义序列对它们进行编码: dictionary[
我是一名优秀的程序员,十分优秀!