2013-06-24 2 views
0

다음은 SOAP 1.2 요청 및 응답의 샘플입니다. 표시된 자리 표시자는 실제 값으로 대체해야합니다.ColdFusion 비누 클라이언트

POST /CommunicationOfficeService1_0/CompanyAccountXmlService.asmx HTTP/1.1 
Host: webservices.nbs.rs 
Content-Type: application/soap+xml; charset=utf-8 
Content-Length: length 

<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
    <soap12:Header> 
    <AuthenticationHeader xmlns="http://communicationoffice.nbs.rs"> 
     <UserName>string</UserName> 
     <Password>string</Password> 
     <LicenceID>guid</LicenceID> 
    </AuthenticationHeader> 
    </soap12:Header> 
    <soap12:Body> 
    <GetCompanyAccountByNationalIdentificationNumber xmlns="http://communicationoffice.nbs.rs"> 
     <nationalIdentificationNumber>long</nationalIdentificationNumber> 
    </GetCompanyAccountByNationalIdentificationNumber> 
    </soap12:Body> 
</soap12:Envelope> 

HTTP/1.1 200 OK 
Content-Type: application/soap+xml; charset=utf-8 
Content-Length: length 

<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
    <soap12:Body> 
    <GetCompanyAccountByNationalIdentificationNumberResponse xmlns="http://communicationoffice.nbs.rs"> 
     <GetCompanyAccountByNationalIdentificationNumberResult>string</GetCompanyAccountByNationalIdentificationNumberResult> 
    </GetCompanyAccountByNationalIdentificationNumberResponse> 
    </soap12:Body> 
</soap12:Envelope> 

는 내가 없음 결과가이

<cfsavecontent variable="soapBody"> 
<cfoutput> 

POST /CommunicationOfficeService1_0/CompanyAccountXmlService.asmx HTTP/1.1 
Host: webservices.nbs.rs 
Content-Type: application/soap+xml; charset=utf-8 
Content-Length: length 

<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
    <soap12:Header> 
    <AuthenticationHeader xmlns="http://communicationoffice.nbs.rs"> 
     <UserName>my_username</UserName> 
     <Password>my_password</Password> 
     <LicenceID>My_licence_id</LicenceID> 
    </AuthenticationHeader> 
    </soap12:Header> 
    <soap12:Body> 
    <GetCompanyAccountByNationalIdentificationNumber xmlns="http://communicationoffice.nbs.rs"> 
     <nationalIdentificationNumber>20774550</nationalIdentificationNumber> 
    </GetCompanyAccountByNationalIdentificationNumber> 
    </soap12:Body> 
</soap12:Envelope> 
</cfoutput> 
</cfsavecontent> 



<!--- 
Now that we have our SOAP body defined, we need to post it as 
a SOAP request to the Campaign Monitor website. Notice that 
when I POST the SOAP request, I am NOT required to append the 
"WSDL" flag to the target URL (this is only required when you 
actually want to get the web service definition). 
---> 
<cfhttp 
url="https://webservices.nbs.rs/CommunicationOfficeService1_0/CompanyAccountXmlService.asmx" 
method="post" 
result="httpResponse"> 

<!--- 
Most SOAP action require some sort of SOAP Action header 
to be used. 
---> 
<cfhttpparam 
type="header" 
name="SOAPAction" 
value="http://communicationoffice.nbs.rs/GetCompanyAccountByNationalIdentificationNumber" 
/> 

<!--- 
I typically use this header because CHTTP cannot handle 
GZIP encoding. This "no-compression" directive tells the 
server not to pass back GZIPed content. 
---> 
<cfhttpparam 
type="header" 
name="accept-encoding" 
value="no-compression" 

/> 

<!--- 
When posting the SOAP body, I use the CFHTTPParam type of 
XML. This does two things: it posts the XML as a the BODY 
and sets the mime-type to be XML. 

NOTE: Be sure to Trim() your XML since XML data cannot be 
parsed with leading whitespace. 
---> 
<cfhttpparam 
type="xml" 
value="#trim(soapBody)#" 
/> 

</cfhttp> 


<!--- 
When the HTTP response comes back, our SOAP response will be 
in the FileContent atribute. SOAP always returns valid XML, 
even if there was an error (assuming the error was NOT in the 
communication, but rather in the data). 
---> 
<cfif find("200", httpResponse.statusCode)> 

<!--- Parse the XML SOAP response. ---> 
<cfset soapResponse = xmlParse(httpResponse.fileContent) /> 

<!--- 
Query for the response nodes using XPath. Because the 
SOAP XML document has name spaces, querying the document 
becomes a little funky. Rather than accessing the node 
name directly, we have to use its local-name(). 
---> 
<cfset responseNodes = xmlSearch(
soapResponse, 
"//*[ local-name() = 'Subscriber.AddAndResubscribeResult' ]" 
) /> 

<!--- 
Once we have the response node, we can use our typical 
ColdFusion struct-style XML node access. 
---> 
<cfoutput> 

Code: #responseNodes[ 1 ].Code.xmlText# 
<br /> 
Success: #responseNodes[ 1 ].Message.xmlText# 

</cfoutput> 

</cfif> 

처럼 보인다는 ColdFusion 코드를 생성했다. 웹 서비스는이 WSDL 파일 나는이에서 사용했던 기능을 수정 한

+0

결과가 나타나지 않거나 오류가 있습니까? 오류가 발생하지 않으면 아마 성공적으로 연결하고있을 것입니다. –

+0

나는 이상한 결과가 나오지 않는다.이 웹 서비스는 날카 롭고 PHP에서 사용하기 쉽지만 자바는 넷빈즈 마법사를 사용하여 모든 올바른 클래스를 생성하지 못하고 콜드 퓨전은 나에게 아무것도 돌려주지 않는다. 웹 사이트와 웹 서비스는 ASP 기술로 만들어집니다. 아마도 뭔가를 놓치고있을 것입니다 ... –

+0

결과가 나오지 않으면 잘못된 기준을 보냈습니다. 연결할 수없는 경우 별도의 오류가 발생해야합니다. –

답변

0

이 웹 서비스를 실행할 수 있도록하는 방법 Serbian National Bank Web Service

에게 있습니다

웹 사이트 사용 과거 비누를 통해 ColdFusion에서 Dynamics GP로 데이터 형식을 전달했습니다.

<cffunction name="callWebService" access="public" output="false"> 
    <cfargument name="soap" type="xml" required="true"> 
    <cfhttp url="https://webservices.nbs.rs/CommunicationOfficeService1_0/CompanyAccountXmlService.asmx" method="post"> 
     <cfhttpparam type="header" name="content-type" value="application/soap+xml"> 
     <cfhttpparam type="header" name="SOAPAction" value="http://communicationoffice.nbs.rs/GetCompanyAccountByNationalIdentificationNumber"> 
     <cfhttpparam type="header" name="accept-encoding" value="no-compression"> 
     <cfhttpparam type="header" name="content-length" value="#len(Arguments.soap)#"> 
     <cfhttpparam type="header" name="charset" value="utf-8"> 
     <cfhttpparam type="xml" name="message" value="#trim(Arguments.soap)#"> 
    </cfhttp> 
    <cfreturn Trim(cfhttp.FileContent)> 
</cffunction> 

나는 당신이 링크 한 웹 서비스에 필요한 <cfhttpparam />s을 업데이트했다고 생각합니다. SOAP UI라는 소프트웨어를 사용하여 ColdFusion 외부의 서비스 및 SOAP XML 본문에 대한 연결을 테스트하는 것이 좋습니다. 위의 함수에서 인수 비누는 저장된 내용 "soapBody"가됩니다.

soapBody에서 한 가지 수정해야합니다. XML 시작 이전의 텍스트는 HTTP 헤더에 있어야하는 데이터에 관한 정보이며,이 값은 <cfhttpparam />으로 전 환됩니다.

위의 코드에서 원하는 200 응답을 얻지 못하는 이유는 XML 본문의 형식이 WSDL HTTP 헤더 예제 텍스트로 잘못 지정 되었기 때문입니다. 나는 또한 선언 된 신체의 길이를 보지 못했다.

연결을 설정하는 동안 서버에서 유효한 비누 응답을보기 시작할 때까지 httpResponse을 덤프하십시오.

+0

감사합니다. 시도해 보겠습니다. –

관련 문제