I try to consume a soap webservice. with ruby net/https gem. No matter what i try, i keep getting 400 Bad Request readbody=true errors I suspect it has something to do with the headers but i don't know how i can get further debugging this. any help is welcome!
Regards,
Remco
require 'net/https'
require 'uri'
# Create the http object
pem = File.read("cert.pem")
url = "https://tstedpwebservice.vecozo.nl/Router.V1.svc/IndienenDeclaratieV1Soap11"
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new(pem)
http.key = OpenSSL::PKey::RSA.new(pem)
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
# Create the SOAP Envelope
xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
xml<<"<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:urn=\"urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1\""
xml<<"xmlns:urn1=\"urn:www-vecozo-nl:messages:vsp:edp:declareren:indienen:v1\""
xml<<"xmlns:urn2=\"urn:www-vecozo-nl:types:vsp:edp:declareren:indienen:v1\">"
xml<<" <soap:Header/>"
xml<<" <soap:Body>"
xml<<" <urn:Indienen>"
xml<<" <urn:IndienenRequest>"
xml<<" <urn1:Declaratie>"
xml<<" <urn2:IndienerEmailadres>noreply@vecozo.nl</urn2:IndienerEmailadres>"
xml<<" <urn2:ReferentieZorgaanbieder>REF001</urn2:ReferentieZorgaanbieder>"
xml<<" <urn2:EmailNotificaties>"
xml<<" <urn2:IndicatieControleResultaat>false</urn2:IndicatieControleResultaat>"
xml<<" <urn2:IndicatieAfkeuringResultaat>true</urn2:IndicatieAfkeuringResultaat>"
xml<<" </urn2:EmailNotificaties>"
xml<<" <urn2:DeclaratieBestand>"
xml<<" <urn2:Bestandsnaam>bestandsnaam.txt</urn2:Bestandsnaam>"
xml<<" <urn2:Bestandsgrootte>1254</urn2:Bestandsgrootte>"
xml<<" <urn2:Data>aZFQ=</urn2:Data>"
xml<<" </urn2:DeclaratieBestand>"
xml<<" </urn1:Declaratie>"
xml<<" </urn:IndienenRequest>"
xml<<" </urn:Indienen>"
xml<<" </soap:Body>"
xml<<"</soap:Envelope>"
xml<<"</xml>"
# Set Headers
headers={
"Accept-Encoding"=>"gzip, deflate",
"Content-Type" => 'text/xml; charset=UTF-8',
"SOAPAction" => "urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1:Indienen",
"User-Agent"=>"Jakarta Commons-HttpClient/3.1",
"Host"=>"edpwebservice.vecozo.nl",
"Content-Length"=> xml.length.to_s
}
result= http.post(uri.path, xml, headers)
puts result.inspect
this is de wsdl, I hope this helps:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:tns="urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1"
xmlns:types="urn:www-vecozo-nl:types:vsp:edp:declareren:indienen:v1"
xmlns:msg="urn:www-vecozo-nl:messages:vsp:edp:declareren:indienen:v1"
xmlns:ia="urn:www-vecozo-nl:isalive:v1"
xmlns:iam="urn:www-vecozo-nl:messages:isalive:v1"
targetNamespace="urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:fault="urn:www-vecozo-nl:types:vsp:edp:faultcontract"
name="VspEdpIncomingZvlIndienen">
<wsdl:types>
<xs:schema targetNamespace="urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1" elementFormDefault="qualified">
<!-- Types -->
<xs:import schemaLocation="./Schemas/V1/Vecozo.Vsp.ISEIBestand.Edp.Indienen.Types.xsd" namespace="urn:www-vecozo-nl:types:vsp:edp:declareren:indienen:v1" />
<!-- Messages -->
<xs:import schemaLocation="./Schemas/V1/Vecozo.Vsp.ISEIBestand.Edp.Indienen.Messages.xsd" namespace="urn:www-vecozo-nl:messages:vsp:edp:declareren:indienen:v1" />
<!-- Fault -->
<xs:import schemaLocation="./Schemas/V1/Vecozo.Vsp.Edp.FaultContract.xsd" namespace="urn:www-vecozo-nl:types:vsp:edp:faultcontract" />
<!-- Requests & Responses -->
<xs:element name="Indienen">
<xs:complexType>
<xs:sequence>
<xs:element name="IndienenRequest" type="msg:IndienenRequest" nillable="true" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="IndienenResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="IndienenResult" type="msg:IndienenResponse" nillable="true" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="VspEdpFaultContract" type="fault:VspEdpFaultContract" />
</xs:schema>
</wsdl:types>
<wsdl:message name="IndienenSoapIn">
<wsdl:part name="parameters" element="tns:Indienen" />
</wsdl:message>
<wsdl:message name="IndienenSoapOut">
<wsdl:part name="parameters" element="tns:IndienenResponse" />
</wsdl:message>
<wsdl:message name="VspEdpIncomingZvlIndienenFaultContract_FaultMessage">
<wsdl:part name="detail" element="tns:VspEdpFaultContract" />
</wsdl:message>
<wsdl:portType name="VspEdpIncomingZvlIndienen">
<wsdl:operation name="Indienen">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Via deze methode kan men declaraties indienen bij VECOZO.</wsdl:documentation>
<wsdl:input开发者_运维技巧 wsaw:Action="urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1:Indienen" message="tns:IndienenSoapIn" />
<wsdl:output wsaw:Action="urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1:IndienenResponse" message="tns:IndienenSoapOut" />
<wsdl:fault wsaw:Action="urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1:IndienenFault"
name="VspEdpFaultContract"
message="tns:VspEdpIncomingZvlIndienenFaultContract_FaultMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="VspEdpIncomingZvlIndienenBinding12" type="tns:VspEdpIncomingZvlIndienen">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Indienen">
<soap12:operation soapAction="urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1:Indienen" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
<wsdl:fault name="VspEdpFaultContract">
<soap12:fault name="VspEdpFaultContract" use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="VspEdpIncomingZvlIndienenBinding" type="tns:VspEdpIncomingZvlIndienen">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Indienen">
<soap:operation soapAction="urn:www-vecozo-nl:vsp:edp:declareren:indienen:v1:Indienen" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="VspEdpFaultContract">
<soap:fault name="VspEdpFaultContract" use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="VspEdpIncomingZvlIndienen">
<wsdl:port name="VspEdpIncomingZvlIndienen12" binding="tns:VspEdpIncomingZvlIndienenBinding12">
<soap12:address location="https://edpwebservice.vecozo.nl/Router.V1.svc/IndienenDeclaratieV1" />
</wsdl:port>
<wsdl:port name="VspEdpIncomingZvlIndienen" binding="tns:VspEdpIncomingZvlIndienenBinding">
<soap:address location="https://edpwebservice.vecozo.nl/Router.V1.svc/IndienenDeclaratieV1Soap11" />
</wsdl:port>
</wsdl:service>
I struggled with the same issue for way too long. It turned out that xmlns:soap url in the documentation of vecozo is wrong. It should be http://schemas.xmlsoap.org/soap/envelope/ instead of http://www.w3.org/2003/05/soap-envelope.
精彩评论