2017-01-02 6 views
0

나는이 자바 코드와 SOAP 호출을 만들려고 노력 해요 :비누 요청하여 자바 - 요청 호출 형식 문제

SOAPEnvelope envelope = soapPart.getEnvelope(); 
envelope.addNamespaceDeclaration("UserAuthentication", serverURI); 
SOAPBody soapBody = envelope.getBody(); 
SOAPElement soapBodyElem = soapBody.addChildElement("UserAuthentication", "UserAuthentication"); 
SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("user_name", "UserAuthentication"); 
soapBodyElem1.addTextNode("[email protected]"); 
SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("password", "UserAuthentication"); 
soapBodyElem2.addTextNode("123"); 
soapMessage.saveChanges(); 

SOAP 호출의 요구 형식 (I 생성하기 위해 노력하고있어)입니다 :

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <UserAuthentication xmlns="http://tempuri.org/"> 
     <user_name>string</user_name> 
     <password>string</password> 
    </UserAuthentication> 
    </soap:Body> 
</soap:Envelope> 

하지만 내 코드에 의해 생성 된 실제 호출이 필요한 형식과 일치하지 않으며 수신 측에서 거부, 나는 알아 내기 위해 노력하고 왜 그것을 해결하는 방법 :

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:UserAuthentication="http://XXX.XXX.XXX.XXX:XXXX/Logininfo.asmx?op=UserAuthentication"> 
<SOAP-ENV:Header/> 
<SOAP-ENV:Body> 
<UserAuthentication:UserAuthentication> 
<UserAuthentication:user_name>[email protected]</UserAuthentication:user_name> 
<UserAuthentication:password>123</UserAuthentication:password> 
</UserAuthentication:UserAuthentication> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 
,536,

답변

0

수신 측의 오류 메시지는 무엇입니까?

어쨌든 UserAuthentication 요소의 네임 스페이스가 다릅니다.

은 예상 : http://tempuri.org/
실제 : http://XXX.XXX.XXX.XXX:XXXX/Logininfo.asmx?op=UserAuthentication

+0

오류는 클라이언트 헤더 문제 –

+0

을 위해 오는 좀 더 구체적인받을 수 있습니까? –

+0

응답 : soap : 클라이언트 서버 는 HTTP 헤더의 SOAPAction의 값을 gnize RECO하지 않았다.

0
envelope.addNamespaceDeclaration("UserAuthentication", serverURI); 

당신이 요청 필요하지 않은 원하는 주어진 왜 당신이 그 네임 스페이스를 추가?

해당 행을 제거해보십시오. 그런 다음이 하나 :

SOAPElement soapBodyElem = soapBody.addChildElement("UserAuthentication", "UserAuthentication"); 

그것을 확인 :

QName bodyName = new QName("http://tempuri.org/", 
    "UserAuthentication", "m"); 
SOAPElement soapBodyElem = soapBody.addChildElement(bodyName);