我似乎无法找到如何在不使用XSD_ANYXML编码的情况下将属性设置为SOAP请求.
请求参数应如下所示
<request
xmlns:ns="/some/ns">
...
<ns:parameter attr="some attribute">
value
</ns:parameter>
...
</request>
Run Code Online (Sandbox Code Playgroud)
当然下面的代码可以工作,但它相当丑陋(丑陋,因为它使用字符串连接,它应该使用SOAP_Client API,因为它不使用通用命名空间)
$param = new SoapVar(
'<ns_xxx:parameter xmlns:ns_xxx="/some/ns" attr="some attribute">
value
</ns_xxx:parameter>',
XSD_ANYXML
);
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来创建具有命名空间和属性的SOAP请求参数?
我正在寻找s.th. 如下所示(这只是使用SoapVar API的一些伪代码):
$param = new SoapVar(
array(
'_' => 'value',
'attr' => 'some attribute'
),
SOME_ENCODING,
null,
null,
null,
'/some/ns'
);
Run Code Online (Sandbox Code Playgroud) 你好,我正在尝试使用Spring-ws. 我对此错误所做的谷歌搜索表明我正在使用 Soap 1.1 并且需要指定 Soap 1.2。我已经尝试这样做了。我下面这样做正确吗?如果这不是问题,有人知道问题是什么吗?
这是堆栈跟踪的一部分:
org.springframework.ws.client.WebServiceTransportException: Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'. [415]
at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:663)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:587)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:537)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:492)
at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:436)
at com.jda.fileserver.FujiAuthenticationTest.testLogin(FujiAuthenticationTest.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Run Code Online (Sandbox Code Playgroud)
这是我的代码,感谢您的帮助:
public class AuthTest {
@Test
public void testLogin() throws Exception {
StringBuffer loginXml = new StringBuffer();
loginXml.append("<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:ns=\"http://abc.com/xyz/2010/08\">");
loginXml.append(" <soapenv:Header>");
loginXml.append(" <ns:loginOperationDetails>");
loginXml.append(" </ns:loginOperationDetails>");
loginXml.append(" </soapenv:Header>");
loginXml.append(" <soapenv:Body>");
loginXml.append(" <ns:LogIn>");
loginXml.append(" …Run Code Online (Sandbox Code Playgroud) 我正在使用SoapUI来测试将由Java客户端应用程序使用的.Net Web服务.
当我将我的Web服务连接到SoapUI但更新WSDL位置并调用其中一个预设测试脚本时,Web服务失败并显示以下代码
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: urn:mycode:us:gu:das:supplierengagement:v02:SupplierEngagement:/AppointSupplier.
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
从上面的错误可以看出,问题在于SOAPAction参数有一个额外的正斜杠.
我在类上使用以下属性:
<WebService(Namespace:= "urn:mycode:us:gu:das:supplierengagement:v02:SupplierEngagement:AppointSupplier")>
Run Code Online (Sandbox Code Playgroud)
以及方法调用的以下属性:
<WebMethod(MessageName:="appointSupplierRq")>
Run Code Online (Sandbox Code Playgroud)
从这些,.Net正在添加正斜杠.
必须可以删除自动生成的正斜杠.
我需要使用基于ASP.NET 4.5应用程序的X.509证书的WS-Security的Web服务.到目前为止,我已经创建了Web引用,但我不知道如何实现WS-Security.我没有获得证书的问题,但我不知道在这种情况下如何使用它,我需要获得如何继续的建议.
到目前为止我的代码非常基本,我需要添加WS-Security:
var tere = new serviciotereSoapClient();
tere.ClientCredentials.ClientCertificate.Certificate = myCert;
var response = tere.agregarGuia( guia );
Run Code Online (Sandbox Code Playgroud)
服务配置:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="serviciotereSoapBinding" >
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://secure.aduana.gov.py/test/tere/serviciotere"
binding="basicHttpBinding" bindingConfiguration="serviciotereSoapBinding"
contract="TEREReference.serviciotereSoap" name="serviciotereSoap" />
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
编辑1
基于@TrevorBrooks的答案,我带来了以下实现:
web.config现在看起来像这样:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_TereService" >
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://secure.aduana.gov.py/test/tere/serviciotere" …Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个WS客户端,需要在将请求发送到服务器之前对其进行签名.我有一个私钥和证书用于此目的,但我正在努力与安全标头.输出XML的预期结构应该是这样的:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-
1.0.xsd"><wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="CertId-45..."
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-
1.0.xsd"> ... </wsse:BinarySecurityToken><ds:Signature Id="Signature-13"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#id-14">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>62...</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
...
</ds:SignatureValue>
<ds:KeyInfo Id="KeyId-...">
<wsse:SecurityTokenReference wsu:Id="STRId-..." xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-
wss-wssecurity-utility-1.0.xsd"><wsse:Reference URI="#CertId-..." ValueType="http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature></wsse:Security></soapenv:Header>
<soapenv:Body wsu:Id="id-14" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
Run Code Online (Sandbox Code Playgroud)
我尝试使用xmlseclibs但我无法弄清楚如何包含所有必需的信息,因为这些示例非常基本.
我想我可以采用DIY方式并手动构建标题,但我希望尽可能简单.
有线索吗?
我目前正在使用SoapClient执行此任务.事情是,我不知道该怎么做.我发送的XML需要签名其内容,我手动完成(使用c14n函数并计算其摘要..).但是,为了对整个身体做同样的事情,我需要访问原始XML(我想),所以我认为这不会起作用.
我没有尝试手动创建SOAP标头,因为我试图避免任何黑客攻击.我正在寻找既易于实现又易于使用的东西.
我的代码目前看起来像这样(将其保持在最低限度以提高可读性):
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'allow_self_signed' => true,
'ciphers'=>'SSLv3'
)
));
$client = new SoapClient($url, array(
//'connection_timeout' => 100,
/* …Run Code Online (Sandbox Code Playgroud) 我有一个Web服务的WSDL(https://facturaelectronica.dian.gov.co/habilitacion/B2BIntegrationEngine/FacturaElectronica/facturaElectronica.wsdl),它指定它是SOAP 1.1并且应该使用WS-Security.
生成的SOAP标头应该像这样的样本:
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>8ac82326-3016-430f-8d69-9efc4bcefd8f</wsse:Username>
<wsse:Password>6361b7b5322acb07ced00a35a85a4cc5183da3a42ede0b07f5780 67a18425a55</wsse:Password>
<wsse:Nonce>FmbZRkx1jh2A+imgjD2fLQ==</wsse:Nonce>
<wsu:Created>2015-07-31T16:34:33.762Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
Run Code Online (Sandbox Code Playgroud)
有关如何在C#中执行此操作的任何建议?(试图使用WSE3.0和WCF,但没有工作)
谢谢.
路易斯
我移植过,将其与开发的代码suds 0.6过来zeep 2.4.0.
以前的泡沫代码:
client = Client(WSDLfile, proxy=proxy, faults=True)
config = client.factory.create('perUserDataExportConfiguration')
config.param1 = 'something'
...
data = client.service.exportPerUserData(username,password,config)
Run Code Online (Sandbox Code Playgroud)
密码:
session = requests.Session()
session.verify = False
transport = Transport(session=session)
client = Client(WSDLfile, strict=False, transport=transport)
config = client.type_factory('ns0').perUserDataExportConfiguration()
config.param1 = 'something'
...
data = client.service.exportPerUserData(username,password,config)
Run Code Online (Sandbox Code Playgroud)
然后我明白了zeep.exceptions.ValidationError: Missing element param_i_didnt_set.看config.__values__演出
OrderedDict([('param1', 'something'),
('param_i_didnt_set', None), ...])
Run Code Online (Sandbox Code Playgroud)
该suds config对象的类似之处在于它包含许多带有空变量的键,但suds不会抛出ValidationErrors.
我正在开发一个使用 SOAP 请求使用 Web 服务的应用程序。
有时我会收到此错误:
filters.LoggerFilter:92 - org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.Error: javax.xml.soap.SOAPException: Unable to create SAAJ meta-factoryProvider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
Run Code Online (Sandbox Code Playgroud)
奇怪的是我随机得到这个错误,但我似乎无法找出原因。
我什至添加了一个新的依赖项,但它似乎并没有解决这个问题:
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 PowerShell 6 上使用 SOAP Web 服务。我曾经New-WebServiceProxy在早期版本上使用该命令执行此任务,但在 PowerShell 6 上不再存在。是否有任何类似的命令?
我需要调用没有 WSDL 的 SOAP API。
API 服务器是用 Perl 编写的SOAP::Lite,并且用作SOAP::Lite客户端,无需 WSDL。我正在尝试zeep使用sudspython,但它们都需要 WSDL。
如何在没有 WSDL 的情况下使用 SOAP API?
是否有任何肥皂库可以在没有 WSDL 的情况下工作?
soap-client ×10
soap ×6
web-services ×3
c# ×2
php ×2
python ×2
ws-security ×2
asp.net ×1
java ×1
powershell ×1
spring ×1
spring-ws ×1
suds ×1
vb.net ×1
wcf ×1
wsdl ×1
xml ×1
xmlseclibs ×1
zeep ×1